Data types that DCLGEN uses for variable declarations

DCLGEN produces declarations for tables and views and the corresponding host variable structures for C, COBOL, and PL/I programs. DCLGEN derives the variable names and data types for these declarations based on the source tables in the database.

The following table lists the C, COBOL, and PL/I data types that DCLGEN uses for variable declarations based on the corresponding SQL data types that are used in the source tables. var represents a variable name that DCLGEN provides.

Table 1. Type declarations that DCLGEN generates
SQL data type1 C COBOL PL/I
SMALLINT short int PIC S9(4) USAGE COMP-5 BIN FIXED(15)
INTEGER long int PIC S9(9) USAGE COMP-5 BIN FIXED(31)
BIGINT long long int PIC S9(18) USAGE COMP-5 FIXED BIN(63)
DECIMAL(p,s) or NUMERIC(p,s) decimal(p,s)2 PIC S9(p-s)V9(s) USAGE COMP-3 DEC FIXED(p,s)

If p>15, the PL/I compiler must support this precision, or a warning is generated.

REAL or FLOAT(n) 1 <= n <= 21 float USAGE COMP-1 BIN FLOAT(n)
DOUBLE PRECISION, DOUBLE, or FLOAT(n) double USAGE COMP-2 BIN FLOAT(n)
Start of changeDECFLOAT(16)End of change Start of change_Decimal64End of change Start of changen/aEnd of change Start of changeDEC FLOAT(16)End of change
Start of changeDECFLOAT(32)End of change Start of change_Decimal128End of change Start of changen/aEnd of change Start of changeDEC FLOAT(16)End of change
CHAR(1) char PIC X(1) CHAR(1)
CHAR(n) char var [n+1] PIC X(n) CHAR(n)
VARCHAR(n)
struct
{short int var_len;
 char var_data[n];
} var;
10 var.
   49 var_LEN PIC 9(4) 
      USAGE COMP-5.
   49 var_TEXT PIC X(n).
CHAR(n) VAR
CLOB(n)3 SQL TYPE IS CLOB_LOCATOR USAGE SQL TYPE IS CLOB-LOCATOR SQL TYPE IS CLOB_LOCATOR
GRAPHIC(1) sqldbchar PIC G(1) GRAPHIC(1)
GRAPHIC(n)

n > 1

sqldbchar var[n+1];
PIC G(n) USAGE
  DISPLAY-1.4
or
PIC N(n).4
GRAPHIC(n)
VARGRAPHIC(n)
struct VARGRAPH
 {short len;
  sqldbchar data[n];
 } var;
10 var.
   49 var_LEN PIC 9(4) 
      USAGE COMP-5.
   49 var_TEXT PIC G(n) 
      USAGE DISPLAY-1.4
or
10 var.
   49 var_LEN PIC 9(4) 
      USAGE COMP-5.
   49 var_TEXT PIC N(n).4
GRAPHIC(n) VAR
DBCLOB(n)3 SQL TYPE IS DBCLOB_LOCATOR USAGE SQL TYPE IS DBCLOB-LOCATOR SQL TYPE IS DBCLOB_LOCATOR
BINARY(n) SQL TYPE IS BINARY(n) USAGE SQL TYPE IS BINARY(n) SQL TYPE IS BINARY(n)
VARBINARY(n) SQL TYPE IS VARBINARY(n) USAGE SQL TYPE IS VARBINARY(n) SQL TYPE IS VARBINARY(n)
BLOB(n)3 SQL TYPE IS BLOB_LOCATOR USAGE SQL TYPE IS BLOB-LOCATOR SQL TYPE IS BLOB_LOCATOR
DATE char var[11]5 PIC X(10)5 CHAR(10)5
TIME char var[9]6 PIC X(8)6 CHAR(8)6
TIMESTAMP char var[27] PIC X(26) CHAR(26)
TIMESTAMP(0) char var[20] PIC X(19) CHAR(19)
TIMESTAMP(p) p > 0 char var[21+p] PIC X(20+p) CHAR(20+p)
TIMESTAMP(0) WITH TIME ZONE
struct
{short int var_len;
 char var_data[147];
} var;
01 var.
   49 var_LEN 
      PIC S9(4) COMP-5.
   49 var_TEXT 
      PIC X(147).
DCL var CHAR(147) VAR;
TIMESTAMP(p) WITH TIME ZONE
struct
{short int var_len;
 char var_data[148 + p];
} var;
01 var.
   49 var_LEN 
      PIC S9(4) COMP-5.
   49 var_TEXT 
      PIC X(148 + p).
DCL var CHAR(148 + p) VAR;
ROWID SQL TYPE IS ROWID USAGE SQL TYPE IS ROWID SQL TYPE IS ROWID
XML7 SQL TYPE IS XML AS CLOB(1M) SQL TYPE IS XML AS CLOB(1M) SQL TYPE IS XML AS CLOB(1M)
Notes:
  1. For a distinct type, DCLGEN generates the host language equivalent of the source data type.
  2. If your C compiler does not support the decimal data type, edit your DCLGEN output and replace the decimal data declarations with declarations of type double.
  3. For a BLOB, CLOB, or DBCLOB data type, DCLGEN generates a LOB locator.
  4. DCLGEN chooses the format based on the character that you specify as the DBCS symbol on the COBOL Defaults panel.
  5. This declaration is used unless a date installation exit routine exists for formatting dates, in which case the length is that specified for the LOCAL DATE LENGTH installation option.
  6. This declaration is used unless a time installation exit routine exists for formatting times, in which case the length is that specified for the LOCAL TIME LENGTH installation option.
  7. The default setting for XML is 1M; however, you might need to adjust it.