Background documentationPosition Description Locate this document in the navigation structure

 

You use syntax rule field_spec to describe either a start position of a data field or a start and an end position of a data field. These can be:

  • The position of the input field in the data stream when importing application data (Column Description)

  • The position of an output field in the data stream when exporting application data (Output Column)

  • The position of a comparison value for importing application data selectively (Selecting Data Records)

Structure

Syntax Syntax

  1. <field_spec> ::=
      <unsigned_integer>
    | <unsigned_integer> - <unsigned_integer>
End of the code.

In the column description, specify a position description field_spec for every column. The position description depends on the format of the data stream.

Format CSV

The data fields do not have a uniform format. They are separated by commas and end with a line break. Enter position descriptions field_spec as relative positions only. If you enter position descriptions with start and end positions for single columns or all columns, Loader generates an error and terminates the command.

Example Example

EXPORT COLUMNS * FROM hotel.reservation

MAP COLUMNS

  rno       1

  cno       2

  hno       3

  type      4

  arrival    5

  departure  6–15    ERROR

DATA OUTSTREAM 'reservation_csv.data' CSV

End of the example.

Assign position 1 to the first column in your list. The position number is incremented by 1 for each further column. This also means that each position number can only be assigned once. If you do not observe these rules, Loader generates an error and terminates the command.

Example Example

EXPORT COLUMNS * FROM hotel.reservation

MAP COLUMNS

  rno       1

  cno       2

  hno       3

  type      4

  arrival    5

  departure  6

  type      7

DATA OUTSTREAM 'reservation_csv.data' CSV

End of the example.

You can assign a column to multiple positions.

Example Example

Data stream customer_csv.data with data at position 1, 2, 3, 4, ...

"3000","Mrs","Jenny","Porter",...

"3100","Mr","Peter","Brown",...

"3200","Company","?","Datasoft",...

Import Command

IMPORT TABLE hotel.customer

DATA INSTREAM 'customer_csv.data'

  cno       1

  title     2

  firstname  3

  name      4

  zip       5

  address    6

PAGE WITH 80% USAGE

End of the example.
Format FWV

The data fields have a standard format, and end with a line break. Specify all position descriptions field_spec with their exact start and end positions. Specify ascending, non-overlapping values only for position descriptions. If the positions entered are not consecutive, Loader fills the gaps with blank characters. This also applies to binary data.

Example Example

EXPORT COLUMNS * FROM hotel.reservation

MAP COLUMNS

  rno       01-05

  cno       06-10

  hno       11-15

  type      16-21

  arrival    25-34

  departure  36-45

DATA OUTSTREAM 'reservation_fwv.data' FWV

End of the example.

Example Example

Data stream customer_fwv.data

-3000Mrs----Jenny-----Porter

-3100Mr-----Peter-----Brown-

-3200Company?---------Dataso

Import Command

IMPORT TABLE hotel.customer

DATA INSTREAM 'customer_fwv.data' FWV

  cno       01-05

  title     06-12

  firstname  13-22

  name      23-32

  zip       33-37

  address    38-62

PAGE WITH 80% USAGE

End of the example.

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 to the left and blank characters are entered to correct the length.

  • Numeric values are aligned to the right and blank characters are entered to correct the length.

If you define a position for the data stream that is shorter than the length of the value in the database, Loader generates an error and terminates the command.

Format FWV BINARY

The data fields have a standard format and do not end with a line break.

Example Example

IMPORT TABLE hotel.customer

DATA INSTREAM 'customer_fwv_binary.data' FWV BINARY

  cno       01-05

  title     06-12

  firstname  13-22

  name      23-32

  zip       33-37

  address    38-62

PAGE WITH 80% USAGE

End of the example.