Definition Attributes
Data Definition Language (DDL) Reference Manual — 426798-002
6- 60
TYPE Clause
If the TYPE clauses in the ORDERINFO definition were replaced by the structures they
represent, the definition would look like this:
DEF orderinfo.
02 employee.
03 last-name PIC X(10).
03 first-name PIC X(20).
02 ordernum PIC 9(3)
HEADING "Order
Number".
02 orderdt TYPE SQL DATETIME YEAR TO DAY
HEADING "Order
Date".
02 orderint TYPE SQL INTERVAL MONTH 2
HEADING "Order
Interval".
02 delivdate TYPE SQL DATE
HEADING "Deliv
Date".
02 salesman PIC 9(4)
HEADING "Salesman
#".
02 custnum PIC 9(4)
HEADING "Customer
#".
END
The definition ORDERNUM, referenced by TYPE *, keeps its name in the
ORDERINFO record, but its implicit level 01 is changed to 02, and a new heading
overrides its original heading.
New headings specified for ORDERNUM, ORDERDT, and DELIVDATE override the
heading declared in ORDDATE and DELDATE.
SQL VARCHAR Field Output for C. The following examples show how DDL
translates definitions and descriptions of SQL VARCHAR fields into C source code:
DDL Type
C Type
DEF name TYPE SQL VARCHAR 25
VALUE "Mary"
DEF customer.
02 customer-name TYPE name.
02 address TYPE SQL VARCHAR 29
OCCURS 10 TIMES
END.
#pragma fieldaligh shared2 __name
typedef struct __name
{
short len;
char val[25];
} name_def;
/*value is "Mary"*/
#pragma fieldalign shared2 __cust
typedef struct __cust
{
name_def customer_name;
/*value is "Mary"*/
struct {
short len;
char val[29];
} address[10];
} customer_def