You can use the DATALOAD, DATAEXTRACT, and DATAUPDATE commands to load LONG values to a target table, unload them from a data stream or modify the LONG values in a table. You use the syntax rules longfile_spec_mlt and longfile_spec to define the columns in a target table to which LONG values are to be loaded or from which data stream they are to be unloaded.
<longfile_spec_mlt> ::= <longfile_spec> <longfile_spec_mlt>
<longfile_spec> ::= LONGFILE
<valCOLUMN_ID> <longfile_code_spec>
| LONGFILE <valCOLUMN_NAME> <longfile_code_spec>
| LONGFILE <valCOLUMN_ID> <valFILE_NAME>
[<longfile_code_spec>]
| LONGFILE <valCOLUMN_NAME> <valFILE_NAME>
[<longfile_code_spec>]
valCOLUMN_ID |
Column ID |
valCOLUMN_NAME |
Column name |
valFILE_NAME |
Name and path of the data stream |
The data for LONG values is stored separately from the other data in LONG data streams. These data streams are specified with the syntax rule longfile_spec.
If, when you are unloading LONG values, you specify more LONG data streams than there are LONG output columns in the column list, the Loader ignores the surplus LONG data streams.
If you use one of the first two syntax rules in longfile_spec, it is absolutely essential that you specify longfile_code_spec. In all other cases, this is optional.
· The first two syntax rules relate to unloading/loading in cases where each LONG value of a column is in a separate LONG data stream.
· The other rules relate to unloading/loading in cases where all LONG values of a column are in one LONG data stream.
When application data is unloaded, there are special features, if values with the internal database data type LONG are unloaded.
You can use both variants of the syntax rule to unload the data.
· Always use a column ID for the LONG column that you want to unload even if a column ID is specified in the column list for this column.
· Use the column name if the column name is specified in the column list.
DATAEXTRACT * FROM hotel
OUTSTREAM 'hotel.data'
LONGFILE info 'info.data'
DATAEXTRACT hno, name, zip, address, info FROM
hotel
OUTFIELDS
hno 1
name 2
zip 3
address 4
info 5
OUTSTREAM 'hotel.data'
LONGFILE info 'info.data'
When you unload LONG values, you must differentiate between the following situations:
· Each LONG value to be unloaded in a separate LONG data stream
· All LONG values to be unloaded in one LONG data stream
Each LONG value to be unloaded from a column is written to a separate data stream.
In the command for unloading data, you specify the name of the LONG data stream with a number of placeholders for sequential numbering of the generated LONG data streams for each LONG column that you want to unload.
If the LONG column you want to unload 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 media name generated in this way, the individual LONG data streams are assigned to the corresponding data record in the target table.
Use a sufficient number of numeric characters at the end of the media name as a placeholder. If the upper limit is reached while the data is being unloaded, but there are still values left to be unloaded, the Loader generates an error message and terminates the command.
DATAEXTRACT hno, name, info FROM hotel
OUTFIELDS
hno 1
name 2
info 3
OUTSTREAM 'hotel.data'
LONGFILE info 'info.data.###'
The Loader
generates the data stream with the name info.data.001 for the first LONG value to be unloaded, the
data stream info.data.002 for the second, and so on.
Content of the target data stream:
"10","Congress","info.data.001"
"20","Long Island","?"
"30","Regency","info.data.002"
All LONG values to be unloaded from a column are written to one data stream.
In the command for unloading data, you specify the name of a data stream for each LONG column, into which each of the LONG values of this LONG column to be unloaded are entered.
If the LONG column you want to unload 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 the start position is always one value larger than the end position.
The start and end position of the generated LONG value in the data stream enable the LONG values to be assigned to data records.
DATAEXTRACT * FROM hotel
OUTFIELDS
hno 1
name 2
info 3
OUTSTREAM 'hotel.data'
LONGFILE info 'info.data'
Content of the target data stream:
"10","Congress","1-915"
"20","Long Island","?"
"30","Regency","916-1074"
When you load LONG values, you can only use the LONGFILE <valCOLUMN_NAME> '<valFILE_NAME>' syntax rule, since you can only use column names in the load command, and not column IDs.
When you load LONG values, you must differentiate between the following situations:
· Each LONG value to be loaded in a separate LONG data stream
· All long values to be loaded in one long data stream
Each LONG value to be loaded to a column is in a separate data stream.
In the data stream, you specify the names of the data streams that contain the LONG values instead of the column values (if necessary, also entering position specifications). The entire data streams or parts of them are loaded as LONG values.
The complete data stream is loaded as LONG values.
DATALOAD TABLE hotel
hno 1
name 2
info 3
INSTREAM 'hotel.data'
Content of the data stream:
"10","Congress","'CONGRESS.LNG'"
"20","Long Island","?"
"30","Regency","'REGENCY.LNG'"
Parts of the data stream are loaded as LONG values.
DATALOAD TABLE hotel
hno 1
name 2
info 3
INSTREAM 'hotel.data'
Content of the data stream:
"10","Congress","'CONGRESS.LNG'
1-915"
"20","Long Island","?"
"30","Regency","'REGENCY.LNG'
1-159"
You can also specify a code attribute in the load command for all data streams that contain LONG values that are to be loaded. To do so, use the syntax rule longfile_code_spec. You can only enter a single code attribute for all data streams. You cannot specify a code attribute for each individual data stream that is specified.
Specifying the Code Attribute ASCII
DATALOAD TABLE hotel
hno 1
name 2
info 3
INSTREAM 'hotel.data'
LONGFILE info ASCII
Content of the data stream:
10,Congress,'CONGRESS.LNG'
30,Regency,'REGENCY.LNG'
60,Airport,'AIRPORT.LNG'
No media name can be used after the keyword LONGFILE.
All LONG values to be loaded to a column are in one data stream.
In the data stream, you specify the name of the data stream containing the LONG values with the start and end position of the LONG value to be loaded, instead of a column value.
DATALOAD TABLE hotel
hno 1
name 2
info 3
INSTREAM 'hotel.data'
Content of the data stream:
"10","Congress","'HOTEL.LNG' 1-915"
"20","Long Island","?"
"30","Regency","'HOTEL.LNG' 916-1074"
You specify the name of the data stream that contains the LONG values after the keyword LONGFILE. In the data stream itself, specify only the position specifications. Do not enter the data stream name as a prefix.
DATALOAD TABLE hotel
hno 1
name 2
info 3
INSTREAM 'hotel.data'
LONGFILE info 'HOTEL.LNG'
Content of the data stream:
"10","Congress","1-915"
"20","Long Island","?"
"30","Regency","916-1074"
In the load command, you can also specify a code attribute for data streams specified with LONGFILE. To do so, use the syntax rule longfile_code_spec.
Specifying the Code Attribute ASCII
DATALOAD TABLE hotel
hno 1
name 2
info 3
INSTREAM 'hotel.data'
LONGFILE info 'HOTEL.LNG' ASCII
Content of the data stream:
"10","Congress","1-915"
"20","Long Island","?"
"30","Regency","916-1074"