Previous Topic Next topic Print topic


SQL/COBOL Data Type Mappings

The following table shows the mappings used by OpenESQL when converting between ODBC SQL and COBOL data types.

ODBC SQL Type COBOL Picture Notes
SQL_CHAR(n)1 PIC X(n)  
SQL_NCHAR(n)1 PIC X(n) or PIC N(n)  
SQL_VARCHAR(n)1 PIC X(n)  
SQL_NVARCHAR(n)1 PIC X(n) or PIC N(n)  
SQL_LONGVARCHAR1 PIC X(max) or SQL TYPE LONG-VARCHAR(max)
SQL_NTEXT1 PIC X(max) or PIC N(max)
SQL_DECIMAL(p,s) or SQL_NUMERIC(p,s) PIC S9(p-s)V9(S) COMP-3 p = precision (total number of digits).

s = scale (number of digits after the decimal point).

OpenESQL doesn’t support using unsigned packed decimal host variables.

SQL_SMALLINT PIC S9(4) COMP-5  
SQL_INTEGER PIC S9(9) COMP-5  
SQL_REAL COMP-1  
SQL_FLOAT COMP-2  
SQL_DOUBLE COMP-2  
SQL_BIT PIC S9(4) COMP-5  
SQL_TINYINT PIC S9(4) COMP-5  
SQL_BIGINT PIC S9(18) COMP-3  
SQL_BINARY(n) PIC X(n) or SQL TYPE BINARY(n)  
SQL_VARBINARY(n) PIC X(n) ) or SQL TYPE VARBINARY(n)  
SQL_LONVARBINARY PIC X(max) or SQL TYPE LONG-VARBINARY(max)  
SQL_DATE or SQL_TYPE_DATE PIC X(10) ) or SQL TYPE DATE yyyy-mm-dd
SQL_TIME or SQL_TYPE_TIME or SQL_SS_TIME2 PIC X(8) or SQL TYPE TIME or SQL TYPE TIME-RECORD hh:mm:ss
SQL_TIMESTAMP or SQL_TYPE_TIMESTAMP PIC X(29) or SQL TYPE TIMESTAMP or SQL TYPE TIMESTAMP-RECORD yyyy-mm-ddhh:mm:ss.ffffff
SQL_SS_TIMESTAMPOFFSET PIC X(34) yyyy-mm-ddhh:mm:ss.ffffff +/-hh:mm
1For more information on using host variables with international data, particularly PIC N and PIC G host variables, see OpenESQL Globalization Best Practices.
Previous Topic Next topic Print topic