Background documentationData Types Locate this document in the navigation structure

 

For most Loader commands for exporting and importing data, you can specify the data type that the relevant field values in the data stream has or should have. A distinction is made between database-internal and external data types. The external data type and the corresponding internal database data type of the column value in the target table do not have to be identical.

Internal Database Data Types

Internal database data types are the data types defined for the columns in the database table. For an explanation of the internal database data types, see SQL Reference Manual, Data Type (data_type).

External Data Types

External data types are either the data types into which Loader can convert internal database data types when it exports application data or the data types that Loader converts into internal database data types when it imports data. You can specify the external data type for each field value to be exported or imported in the Loader commands for exporting or importing using syntax element field_type.

Structure

Syntax Syntax

  1. <field_type> ::=
      /* empty */
    | CHAR
    | DECIMAL [<unsigned_integer>]
    | INTEGER
    | REAL
    | ZONED [<unsigned_integer>]
End of the code.
External Data Types

/* empty */

The data field is read or output as data type CHAR. Each internal database column format in the database can be read and output in CHAR format.

CHAR

ASCII, UCS2, or UTF8-coded, depending on the computer, max. 254 bytes.

DECIMAL [<unsigned_integer>]

Packed decimally: one digit per half byte, sign in extreme right half byte, 1 to 10 bytes, maximum of 18 digits, the position of the decimal point is derived from the table column type

unsigned_integer: number of digits to the right of the decimal point

INTEGER

Binary coded (computer-specific), 1, 2, or 4 bytes, sign in bit 0, negative values in two's complement notation

REAL

Floating point notation with mantissa and exponent, 4 or 8 bytes, in computer-specific notation

ZONED [<unsigned_integer>]

Zoned decimal: /370 zoned data format is permitted, the position of the decimal point is derived from the type of the table column

unsigned_integer: number of digits to the right of the decimal point

If no external data type is specified for a field value, Loader selects CHAR data type as the default for this field value. Therefore, if the field value does not have data type CHAR or data type CHAR is not required, you need to specify the data type.

Binary Values

All numeric, external data types (INTEGER, REAL, DECIMAL, ZONED) are interpreted as binary values. These can be converted to any of the internal data types (FIXED, SMALLINT, INTEGER, FLOAT) used by the database.

  • Loader always interprets data of data type INTEGER as signed values. You can adjust how this data is represented in a data stream using the syntax element int_spec (see: Data Format).

  • Data of data type REAL is coded in a computer-specific format and cannot be transported between different operating systems and computer platforms without being converted again.

Plain Text Values

Field values with external data type CHAR are plain text values, that is, these values consist of readable characters.

  • Plain text values can conform to different specifications: ASCII, UCS2, or UTF8 (see: Code Specification).

  • You can specify the data formats for plain text values that represent the date, time, or a time stamp (see date, time and time stamp specification).

HEX Values

You can use an external data type with the additional specification HEX (see: Column Description, Output Column) as a hexadecimal value. This enables you to import or export all data types in hexadecimal form. Each byte of data in the result is represented by two hexadecimal numbers. Each value in the data stream occupies twice as much space as the value of the same data type that is not specified as a HEX value.

Converting the Data Types

The specification of the data types tells Loader how to interpret the data in the data stream.

  • If application data is exported from a table, the internal database data types are converted to the specified external data types and the corresponding column values are exported.

  • If application data is imported into a table, the specified external data types are converted to internal database data types and the corresponding column values of a table are imported.

Loader can convert numeric data types. You can use the external data type CHAR to read or output any internal database data type.

  • If data is exported from a table, the internal database data types are converted to the specified external data types and the corresponding column values are exported. The database-internal data types INT[EGER], FIXED and SMALLINT can be transported to the external data types DECIMAL, INTEGER, REAL or ZONED. The database-internal data type FLOAT can be converted to the external data types CHAR[ACTER] or REAL.

  • When data is imported into a table, the specified external data types are converted to internal database data types and the corresponding column values of a table are imported. The external data types DECIMAL, INTEGER, REAL and ZONED can be converted to the database-internal data types INTEGER, FIXED, FLOAT or SMALLINT.

Example

Example Example

IMPORT TABLE hotel.reservation

DATA INSTREAM 'reservation_fwv.data' FWV BINARY

  rno       01-04 INTEGER

  cno       05-08 INTEGER

  hno       09-12 INTEGER

  type     13-18 CHAR

  arrival   19-28 CHAR

  departure 29-38 CHAR

End of the example.

The database table RESERVATION requires the internal database data type FIXED for the values in columns RNO, CNO and HNO. The IMPORT TABLE command defines the external data type INTEGER for these columns. The data in the columns RNO, CNO and HNO is converted to the internal database data type FIXED when it is imported.

Example Example

IMPORT TABLE hotel.room

DATA INSTREAM 'room_fwv_binary.data' FWV BINARY

  hno       01-05

  type      06-11

  free      12-19 INTEGER HEX

  price     20-27 INTEGER HEX

End of the example.

The IMPORT TABLE command defines hexadecimal values FREE and PRICE as the external data type using the additional HEX specification.