The syntax elements used for the output columns are described below.
See also:
<output_column> := <column_id_spec> | <lit_column_spec>
<column_id_spec> ::= <column_id> <field_pos>
<format_spec>
<null_assign>
<column_id> ::= <valCOLUMN_NAME> | <valCOLUMN_ID>
<null_assign> ::= [IF] NULL SET '<valLITERAL>'
<lit_column_spec> ::= '<valLITERAL>' <field_pos>
valCOLUMN_NAME |
Column name Specify this according to the SQL conventions. It can also contain the table name as a prefix (such as customer.cno). |
valCOLUMN_ID |
Column ID |
valLITERAL |
null_assign: null value representation lit_column_spec: text constant |
You use the syntax element column_id_spec in unload commands to assign the data fields of the data stream to the columns of the source table. You specify the external data types and the conditions for unloading the application data.
You use the syntax rule column_id to specify the column name or column number.
DATAEXTRACT cno, name, zip, address FROM
customer
OUTFIELDS
cno 01-05
name 06-15
zip 16-20
address 21-45
OUTSTREAM 'customer.data' FORMATTED
The column number valCOLUMN_ID indicates the position of the column in the SELECT statement.
DATAEXTRACT cno, name, zip, address FROM
customer
OUTFIELDS
1 01-05
2 06-15
3 16-20
4 21-45
OUTSTREAM 'customer.data' FORMATTED
Decide whether you want your column descriptions to contain field_pos field descriptions. However, you must specify position descriptions for all or none of the described columns. Otherwise, the Loader generates an error and terminates the command.
Enter position descriptions field_pos as relative positions only.
If you enter position descriptions with start and end positions for single columns or all columns, the Loader generates an error and terminates the command.
DATAEXTRACT * from reservation
OUTFIELDS
rno 1
cno 2
hno 3
type 4
arrival 5
departure 6-15 ERROR
OUTSTREAM 'reservation.data' COMPRESSED
Assign position 1 to the first column in your list. The position numbers of the following columns increase by 1 each time. This also means that each position number can only be assigned once.
If you do not observe these rules, the Loader generates an error and terminates the command.
DATAEXTRACT * from reservation
OUTFIELDS
rno 1
cno 2
hno 3
type 4
arrival 5 ERROR
departure 6
OUTSTREAM 'reservation.data' COMPRESSED
You can assign a column to several different positions.
DATAEXTRACT * from
reservation
OUTFIELDS
rno 1
cno 2
hno 3
type 4
arrival 5
departure 6
type 7
OUTFILE 'reservation.data' COMPRESSED
Specify all position descriptions with exact start and end positions.
Specify only
ascending, non-overlapping values for position descriptions.
If the positions entered are not consecutive, the Loader fills the gaps with
blank characters. This also applies to binary data.
DATAEXTRACT * from
reservation
OUTFIELDS
rno 01-05
cno 06-10
hno 11-15
type 16-21
arrival 25-34
departure 36-45
OUTFILE 'reservation.data'
FORMATTED
Define the
positions for the data stream so that they are at least as long as the length
of the values in the database.
If you define a position for the data stream that is longer than the
length of the value in the database, the following occurs:
· Character strings are aligned left and blank characters entered to make them the correct length.
· Numeric values are aligned right and blank characters entered to make them the correct length.
If you define a position for the data stream that is shorter than the length of the value in the database, the Loader generates an error and terminates the command.
You use the syntax element null_assign in a command for unloading data to specify which value for the data field of the source table is written to the data stream if the value in the source table is a NULL value.
Place the value for the NULL value representation in single quotation marks. This is a plain text value that the Loader represents as a character string or binary numeric value. This depends on the external data type of the column for which you want to generate the null value representation.
If you want to display the null value representation in one of the external data types for binary values, it must have a valid numeric format. This means either a floating decimal number in mantissa/exponent representation or a fixed point number with the currently agreed or standard decimal setting.
The generated null value representation is written to the same place in the data stream as the actual column value.
· If the null value representation is shorter than the length of the value specified by the position, the value is filled with blank characters. If the null value representation is longer, it is shortened to the specified length, and the Loader generates a warning.
· If columns in the target table permit NULL values and you have not specified a NULL value representation, the Loader default is used for unloaded NULL values (NULL_specification). This has the external data type CHAR.
· If you define a null value representation for unloading NOT-NULL columns, it does not cause an error.
You want to
unload the source table room from the database instance into the room.data
data stream. Some of the
columns in the table contain NULL values.
Define a separate condition for each of these columns. If this condition is
met, the corresponding null value representation is entered in the data
stream.
DATAEXTRACT * FROM room
OUTFIELDS
hno 1
type 2
free 3 IF NULL SET '0'
price 4 IF NULL SET 'X'
OUTSTREAM 'room.data'
You want to
unload the source table room from the database instance into the room.data
data stream. Some of the
columns in the table contain NULL values.
Because no null value representation is defined for the column in the command,
but all values have the external data type CHAR, the Loader default null value
representation '?' is used.
DATAEXTRACT * FROM room
OUTFIELDS
hno 1
type 2
free 3
price 4
OUTSTREAM 'room.data'
You want to
unload the source table room from the database instance into the room data stream. Some of the columns in the table
contain NULL values.
Because no null value representation is defined for the column in the command,
the Loader attempts to use the null value representation defined as a default
(data type CHAR). This causes an error if a numeric external data type has
been defined for the columns. The command terminates with an error
message.
DATAEXTRACT * FROM room
hno 01-05
type 06-11
free 12-15 INTEGER
price 16-19 INTEGER
OUTSTREAM 'room.data' FORMATTED BINARY
You use the syntax element lit_column_spec to define text constants for output in addition to the output values in the unload command.
The text constant is specified in single quotation marks instead of the column name or column ID (column_id).
DATAEXTRACT * from customer
OUTFIELDS
'customer number:' 01-12
cno 13-17
title 18-24
firstname 25-34
name 35-44
zip 45-49
address 50-74
OUTSTREAM 'customer.data' FORMATTED