## Importing LONG Values

You can use the IMPORT TABLE and IMPORT/UPDATE COLUMNS commands to import (or update) LONG values to a target table.

Using the appropriate syntax rules, you can define which of a target table’s columns the LONG values are exported to or which of the columns are updated.

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

### Prerequisites

If you want to carry out an import, the data must have been exported or it must be in the appropriate format. The LONG values that you require are in the LONG data streams.

See also:

Exporting LONG Values

### Syntax

<import_lobcolumn_spec> ::= LOB <instream_lob_spec>
<instream_lob_spec> ::= INSTREAM [FILE] <column_spec> <lob_code_spec>
| INSTREAM [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 of 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 imported. The column ID reflects the position of the column in the column list.

Specifying the LONG column name INFO

IMPORT TABLE hotel.hotel
DATA INSTREAM 'hotel_csv.data'
LOB INSTREAM info 'hotel_info.data'

Specifying the COLUMN ID of the LONG column INFO

IMPORT TABLE hotel.hotel
DATA INSTREAM 'hotel_csv.data'
LOB INSTREAM 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 imported 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

IMPORT TABLE hotel.hotel
DATA INSTREAM 'hotel_csv.data'
LOB INSTREAM info 'hotel_info.data' ASCII

See also:

Code Specification

### Specifying the LONG Data Stream <stream_name>

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

● Each LONG value to be imported is in a separate LONG data stream.

● All of a column’s LONG values that are to be imported are in one LONG data stream.

#### Each LONG Value to be Imported Is in a Separate LONG Data Stream

You do not need to use any of the LOB syntax rules in the IMPORT command, as the Loader evaluates the DATA data stream. After the corresponding export has been carried out (Exporting LONG Values, Each Long Value to be Exported is Exported in a Separate Long Data Stream), the column values are replaced in the DATA data stream by the names of the LONG data streams that are to be imported (if required, the sequential numbering is extended). The LONG data streams are imported in their entirety as LONG values.

The LONG data streams are imported in their entirety as LONG values

IMPORT TABLE hotel.hotel
DATA INSTREAM 'hotel_csv.data'
hno 1
name 2
zip 3
address 4
info 5 DEFAULT NULL

Content of the DATA 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"

You can also use the LOB INSTREAM [FILE] <column_spec> <lob_code_spec> syntax rule in the IMPORT command if you want the values in the LONG data streams to be imported according to the code type specified. In this case, the names of the LONG data streams that are to be imported also take the place of the column values (if necessary, the sequential numbering is extended). The LONG data streams are imported in their entirety as LONG values.

The LONG data streams are imported in their entirety as LONG values and are read in binary

IMPORT TABLE hotel.hotel
DATA INSTREAM 'hotel_csv.data'
hno 1
name 2
zip 3
address 4
info 5 DEFAULT NULL
LOB INSTREAM info BINARY

Content of the DATA 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"

#### All of a Column’s LONG Values that are to be Imported are in One LONG Data Stream

You use syntax rule LOB INSTREAM [FILE] <column_spec> '<stream_name>' to specify the LONG data stream. After the corresponding export has been carried out (Exporting LONG Values, All LONG Values to be Exported are Exported to One LONG Data Stream), the column values are replaced in the DATA data stream by the positions of the LONG values in the LONG data stream.

IMPORT TABLE hotel.hotel
DATA INSTREAM 'hotel_csv.data'
hno 1
name 2
zip 3
address 4
info 5 DEFAULT NULL
LOB INSTREAM info 'hotel_info.data'

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

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

You can use the LOB INSTREAM [FILE] <column_spec> '<stream_name>' syntax rule in the IMPORT command if you want the values in the LONG data streams to be imported according to the code type specified. In this case, it is also only the positions of the LONG values in the LONG data stream that are specified in the DATA data stream.

IMPORT TABLE hotel.hotel
DATA INSTREAM 'hotel_csv.data'
hno 1
name 2
zip 3
address 4
info 5 DEFAULT NULL
LOB INSTREAM info 'hotel_info.data' ASCII

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

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