FairCom RTG COBOL Edition maps COBOL data types into SQL types. The mapping depends on the settings in the XDD file and compilation settings at runtime.
The table below shows the default mapping. It is also possible to force mapping to a particular data type by using the dbtype attribute in the XDD.
USAGE |
PIC |
SQL type |
---|---|---|
DISPLAY |
9 S V |
NUMERIC |
|
A X |
CHAR |
BINARY |
|
See Number Mapping table |
COMP |
|
See Number Mapping table |
COMP-4 |
|
See Number Mapping table |
COMP-X |
|
See Number Mapping table |
COMP-5 |
|
See Number Mapping table |
COMP-1 |
|
REAL (NUMERIC for ACU) |
COMP-2 |
|
REAL (NUMERIC for ACU) |
COMP-3 |
|
NUMERIC |
COMP-6 |
|
NUMERIC |
Number Mapping
The table below describes the mapping of numbers. The mapping used will be the first case that applies (e.g., if the PIC contains a V, that rule will be used regardless of the size in bytes). For the size in bytes or the number of digits of COBOL types, please check the compiler/runtime documentation.
PIC contains V (there is a decimal separator) |
NUMERIC |
Size in bytes 1 |
TINYINT |
Size in bytes 2 |
SMALLINT |
Size in bytes 3-4 |
INTEGER |
Size in bytes 5-8 |
BIGINT |
Size in bytes >8 |
BINARY |
Variable Length Fields
Variable length fields map into SQL LONGVAR* fields.
The XDD structure allows the following elements and attributes for variable length field support.
For an XDD field mapped into a LONG VARCHAR or LONG VARBINARY, the following conditions must be met:
size="0"
sizefield="X" where "X" is a valid field containing the number of bytes (we suggest this field to be hidden, but this is not mandatory)
dbtype="clob" or dbtype="blob"
If one (or more) of the above condition is not met, error CTDBRET_CALLBACK_11 ("Unsupported clob/blob definition") is returned.
COBOL has no "date" type, however it has a standard function called integer_of_date, which takes a COBOL number of the form YYYYMMDD and generates an integer that is the number of days since Dec. 31 1600 (therefore a Julian date). When linking such a date into SQL, the julianBase would be "16001231". However, such a julianBase cannot be specified because the value needs to be in c-tree valid date range, which is not earlier than March 3 1700.
It is now possible to specify in the XDD julianBase='integer-of-date' ('integer-of-date' must be lowercase!) to indicate values stored in the record result from an integer-of-date function.