Exporting LONG Values

You can export LONG values in data streams with the EXPORT TABLE and EXPORT COLUMNS commands.

Using the appropriate syntax rules, you can define which data streams the LONG values are exported to. 

Special syntax rules for handling LONG values are not required if you are using the RECORDS or PAGES formats.

Syntax

<export_lobcolumn_spec> ::= LOB <outstream_lob_spec>
<outstream_lob_spec>    ::= OUTSTREAM [FILE] <column_spec> '<stream_name>' [<lob_code_spec>]

<column_spec>          ::= <column_name> | <column_id>
<column_name>          ::= <identifier>
<column_id>            ::= <unsigned_integer>

<lob_code_spec>        ::= <code_spec> | BINARY

<stream_name>

Name of the data stream

This is a data stream of data carrier type FILE.

For special features when assigning the name, see the explanation.

See also: Data Stream

<column_name>

Name of column

See the SQL Reference Manual, Column Name (column_name)

<column_id>

Column ID

See the SQL Reference Manual, Unsigned Integer (unsigned_integer)

Examples

See the Exporting and Importing LONG Values section and the following sections.

Explanation

<column_spec>

You can use the column name (column_name) or the column ID (column_id) for a LONG column that is to be exported. The column ID reflects the position of the column in the column list.

Specifying the LONG column name INFO

EXPORT TABLE hotel.hotel
  DATA OUTSTREAM 'hotel_csv.data'
  
LOB OUTSTREAM info 'hotel_info.data'

Specifying the COLUMN ID of the LONG column INFO

EXPORT TABLE hotel.hotel
  DATA OUTSTREAM 'hotel_csv.data'
  
LOB OUTSTREAM 5 'hotel_info.data'

<lob_code_spec>

You can also specify the code type for all data streams containing LONG values that are to be exported to a column by specifying the syntax rule lob_code_spec. Only one code type can be specified for all the data streams, as the code type has to be specified in the command.

Specifying the ASCII code type

EXPORT TABLE hotel.hotel
  DATA OUTSTREAM 'hotel_csv.data'
  
LOB OUTSTREAM info 'hotel_info.data' ASCII

See also:

Code Specification

Specifying the LONG Data Stream <stream_name>

When you export LONG values, you must distinguish between the following cases:

...

?     Each of a column’s LONG values that is to be exported is exported to a separate LONG data stream.

?     All of a column’s LONG values that are to be exported are exported to one LONG data stream.

Each LONG Value to be Exported Is Exported to a Separate LONG Data Stream

For each LONG value that is to be exported, you use the export command to assign the name of a LONG data stream. After you have specified the LONG column in the export command, you specify the name of the LONG data stream with a number of placeholders for sequential numbering of the generated LONG data streams.

If the LONG column you want to export has no value in a data record (the value is an empty character string), an empty LONG data stream is generated for this LONG value.

Using the unique name generated in this way, the individual LONG data streams can be assigned to the corresponding data record in the target table.

Use a sufficient number of numeric characters at the end of the LONG data stream name as a placeholder. If the upper limit is reached while the data is being exported, but there are still values left to be exported, the Loader generates an error message and terminates the export command.

EXPORT TABLE hotel.hotel
  DATA OUTSTREAM 'hotel_csv.data'
  LOB OUTSTREAM info 'hotel_info.data###'

The Loader generates the LONG data stream with the name hotel_info.data.001 for the first LONG value to be exported, the data stream hotel_info.data.002 for the second, and so on.
Content of the data stream
hotel_csv.data (excerpt):

"10","Congress","20005","155 Beechwood St.","hotel_info.data001"
"20","Long Island","11788","1499 Grove Street","?"
"30","Regency","20037","477 17th Avenue","hotel_info.data002"

See also:

Importing LONG Values, Each LONG Value to be Imported Is in a Separate LONG Data Stream

All Long Values to be Exported Are Exported to One LONG Data Stream

In the command for exporting data, you specify the name of a LONG data stream for each LONG column, into which each of the LONG values of this LONG column to be exported are entered.

If the LONG column you want to export has no value in a data record (the value is an empty character string), the position specification for this LONG value is generated as follows: the start position is the end position of the preceding LONG value in the column plus 1; the end position is the end position of the preceding LONG value in the column. This means that if there is an empty value, the start position is always one value larger than the end position.

The start and end position of the generated LONG value in the LONG data stream enable the LONG values to be assigned to data records.

EXPORT TABLE hotel.hotel
  DATA OUTSTREAM 'hotel_csv.data'
  LOB OUTSTREAM info 'hotel_info.data'

Content of the data stream hotel_csv.data (excerpt):

"10","Congress","20005","155 Beechwood St.","1-994"
"20","Long Island","11788","1499 Grove Street","?"
"30","Regency","20037","477 17th Avenue","995-1157"

See also:

Importing LONG Values, All of a Column’s LONG Values the are to be Imported are in One LONG Data Stream