Release 10.1A: OpenEdge Development:
Progress 4GL Reference

> ## EXPORT statement

> Converts data to a standard character format and displays it to the current output destination (except when the current output destination is the screen) or to a named output stream. You can use data exported to a file in standard format as input to other Progress procedures.

> #### Syntax

>     EXPORT [ STREAM stream ] [ DELIMITER character ]
>       {    expression ...
>          | record [ EXCEPT field ... ]
>       }
>       [ NO-LOBS ]

>     EXPORT [ STREAM stream ] { memptr | longchar }

> `STREAM `stream``

> The name of a stream. If you do not name a stream, Progress uses the unnamed stream. See the DEFINE STREAM statement reference entry in this book and the chapter on alternate I/O sources in OpenEdge Development: Programming Interfaces for more information on streams.

> `DELIMITER `character``

> The character to use as a delimiter between field values. The `character` parameter must be a quoted single character. The default is a space character.

> If you specify more than one character as a delimiter, Progress uses the first character as the delimiter.

> ``expression` . . .`

> One or more expressions that you want to convert into standard character format for display to an output destination.

> ``record``

> The name of the record buffer with fields that you want to convert into the standard character format to display to an output destination.

> To use EXPORT with a record in a table name used in multiple databases, you must qualify the record’s table name with the database name. See the Record phrase reference entry for more information.

> `EXCEPT `field` . . .`

> Progress exports all fields except those fields listed in the EXCEPT phrase.

> ``memptr``

> A variable of data type MEMPTR that contains the text to export. The EXPORT statement may contain a MEMPTR in its field list as long as it is the only field in the list.

> ``longchar``

> A variable of data type LONGCHAR that contains the text to export. The EXPORT statement may contain a LONGCHAR in its field list as long as it is the only field in the list.

> `NO-LOBS`

> Directs Progress to ignore large object data when exporting records that contain BLOB or CLOB fields.

> Examples

> This procedure converts the data in the customer table into standard character format and sends that data to the customer.d file:

> r-exprt.p
>     OUTPUT TO customer.d.
>     FOR EACH customer:
>       EXPORT customer.
>     END.

>     OUTPUT CLOSE.

> The next procedure shows how each EXPORT statement creates one line of data. That is, fields are not wrapped onto several lines.

> r-exprt2.p
>     OUTPUT TO custdump.
>     FOR EACH customer:
>       EXPORT cust-num name credit-limit.
>     END.

>     OUTPUT CLOSE.

> That procedure creates a text file, `custdump`, with one line for each customer. This is a typical line of output:

>     1 "Lift Line Skiing" 58400

> Use the DELIMITER option to specify a character other than a space to separate fields in the output file. For example, the following procedure uses a semicolon:

> r-cstout.p
>     OUTPUT TO custdump2.

>     FOR EACH customer:
>       EXPORT DELIMITER ";" cust-num name credit-limit.
>     END.

>     OUTPUT CLOSE.

> This is a typical line of output from this code:

>     1;"Lift Line Skiing";58400

> The following example displays using a MEMPTR to EXPORT mixed character and binary data:

> r-expmem.p
>     /* character and binary data mixed */

>     DEFINE VARIABLE z AS MEMPTR.

>     SET-SIZE(z) = 100.

>     PUT-STRING(z,1) = "hi there".
>     PUT-LONG(z,10) = 235.
>     PUT-STRING(z,14) = "afterint".
>     PUT-LONG(z,22) = 76.

>     OUTPUT TO abc BINARY NO-CONVERT.
>     EXPORT z.
>     OUTPUT CLOSE.

> #### Notes

> - The EXPORT statement must follow an OUTPUT TO statement, which redirects the output destination.

> - Other procedures can use the data exported with the EXPORT statement as input by reading the file with the INSERT, PROMPT-FOR, SET, UPDATE or IMPORT statements, naming one field or variable to correspond to each data element.

> - The data is in a standard format to be read back into Progress. All character fields are enclosed in quotes ("") and quotes contained in the data you are exporting are replaced by two quotes (""). A single space separates one field from the next. An Unknown value (`?`) is displayed as an unquoted question mark (?).

> - There are no trailing blanks, leading zeros, or formatting characters (for example, dollar signs) in the data.

> - Progress exports logical fields as the value YES or NO.

> - A Format phrase with an EXPORT statement is ignored.

> - If you use a single qualified identifier with the EXPORT statement, the Compiler first interprets the reference as `dbname.tablename`. If the Compiler cannot resolve the reference as `dbname.tablename`, it tries to resolve it as `tablename.fieldname`.

> - When exporting fields, you must use table names that are different from field names to avoid ambiguous references. See the Record phrase reference entry for more information.

> - When exporting RECID fields, you must explicitly state the RECID field name in the EXPORT statement.

> - When exporting ROWID variables or fields in a work table, you must convert the ROWID variable or field to a character string using the STRING function.

> - When exporting records that contain a BLOB or CLOB field, Progress creates a separate object data file using a unique filename with a `.blb` extension and stores that filename in the BLOB or CLOB field of the exported record. (When importing records that contain a BLOB or CLOB field, Progress uses this filename to locate the object data file associated with each record.) If the BLOB or CLOB field contains the Unknown value (`?`), Progress stores the Unknown value (`?`) in the BLOB or CLOB field of the exported record, and does not create an object data file. If the BLOB or CLOB field contains a zero-length object, Progress creates a zero-length object data file.

> Progress raises the ERROR condition if an object data file cannot be created.

> - The EXPORT statement creates large object data files in the directory specified as the output destination in the OUTPUT TO statement, by default. You can use the `LOB-DIR` option on the OUTPUT TO statement to specify the directory in which the EXPORT statement creates the BLOB and CLOB data files.

> - Use the `NO-LOBS` option with the EXPORT statement to ignore large object data when exporting records that contain BLOB or CLOB fields. When you specify the `NO-LOBS` option, Progress stores the Unknown value (`?`) in the BLOB or CLOB field of the exported records and does not create the associated object data files.

> - When exporting DATETIME and DATETIME-TZ data, the data format is
>   fixed and conforms to the ISO 8601 standard for date/time representations (`YYYY-MM-DDTHH:MM:SS.SSS+HH:MM`). For DATETIME, there is no time zone offset.

> - If you use the DELIMITER option of the EXPORT statement to specify a delimiter other than a space character, you must specify the same delimiter character in a subsequent IMPORT statement that loads the data.

> - EXPORT is sensitive to the Date format (-d), Century (-yy), and European numeric (-E) startup parameters. When loading data with the IMPORT statement, use the same settings that you used with the EXPORT statement.

> - In the MEMPTR version of the EXPORT statement, the MEMPTR’s size will determine how much is written to the file. If the size of a MEMPTR is 100, and it only contains a string of length 10, the entire 100 bytes will still be written to the file. The PUT-BYTES statement and GET-BYTES function may be used to move portions of MEMPTRs to areas with varying sizes.You can read and write parts of a file by using MEMPTRs of varying sizes, and multiple EXPORT/IMPORT statements on the same file.

> - When exporting a LONGCHAR variable, Progress also stores the variable’s code page in the file header.

> #### See also

> DEFINE STREAM statement, DISPLAY statement, IMPORT statement, OUTPUT CLOSE statement, OUTPUT TO statement, PUT statement, STRING function

Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095