Académique Documents
Professionnel Documents
Culture Documents
Table 49. SQL Data Types Mapped to COBOL Declarations SQL Column Type SQL Column Type1 COBOL Data Type Description 01 MY-CLOB USAGE IS SQL TYPE IS Large object variableCLOB(n). CLOB(n) length character (408 or 409) string 1<=n<=2 147 483 647 CLOB locator variable4 (964 or 965) CLOB file reference variable4 (920 or 921) BLOB(n) (404 or 405) BLOB locator variable4 (960 or 961) BLOB file reference variable4 (916 or 917) DATE (384 or 385) TIME (388 or 389) TIMESTAMP (392 or 393) XML5 (988 or 989) Identifies CLOB 01 MY-CLOB-LOCATOR USAGE IS SQL entities residing on TYPE IS CLOB-LOCATOR. the server Descriptor for file 01 MY-CLOB-FILE USAGE IS SQL TYPE containing CLOB IS CLOB-FILE. data 01 MY-BLOB USAGE IS SQL TYPE IS BLOB(n). 1<=n<=2 147 483 647 Identifies BLOB 01 MY-BLOB-LOCATOR USAGE IS SQL entities residing on TYPE IS BLOB-LOCATOR. the server Descriptor for file 01 MY-BLOB-FILE USAGE IS SQL TYPE containing BLOB IS BLOB-FILE. data 01 identifier PIC X(10). 01 identifier PIC X(8). 01 identifier PIC X(26). 10-byte character string 8-byte character string 26-byte character string Large object variablelength binary string
The following data types are only available in the DBCS environment. Table 50. SQL Data Types Mapped to COBOL Declarations SQL Column Type SQL Column Type1 COBOL Data Type Description GRAPHIC(n) (468 or 469) VARGRAPHIC(n) (464 or 465) 01 name PIC G(n) DISPLAY-1. 01 name. 49 length PIC S9(4) COMP-5. Fixed-length doublebyte character string Variable length double-byte character
Table 50. SQL Data Types Mapped to COBOL Declarations SQL Column Type SQL Column Type1 COBOL Data Type Description 49 name PIC G(n) DISPLAY-1. string with 2-byte string length indicator 1<=n<=16 336 LONG VARGRAPHIC (472 or 473) 01 name. 49 length PIC S9(4) COMP-5. 49 name PIC G(n) DISPLAY-1. 16 337<=n<=16 350 DBCLOB(n) (412 or 413) DBCLOB locator variable4 (968 or 969) DBCLOB file reference variable4 (924 or 925) Notes: 1. The first number under SQL Column Type indicates that an indicator variable is not provided, and the second number indicates that an indicator variable is provided. An indicator variable is needed to indicate NULL values, or to hold the length of a truncated string. These are the values that would appear in the SQLTYPE field of the SQLDA for these data types. 2. FLOAT(n) where 0 < n < 25 is a synonym for REAL. The difference between REAL and DOUBLE in the SQLDA is the length value (4 or 8). 3. The following SQL types are synonyms for DOUBLE: o FLOAT o FLOAT(n) where 24 < n < 54 is a synonym for DOUBLE. o DOUBLE PRECISION 4. This is not a column type but a host variable type. 5. The SQL_TYP_XML/SQL_TYP_NXML value is returned by DESCRIBE requests only. It cannot be used directly by the application to bind application resources to XML values. Variable length double-byte character string with 2-byte string length indicator
Large object variable01 MY-DBCLOB USAGE IS SQL TYPE IS length double-byte DBCLOB(n). character string with 4-byte string length 1<=n<=1 073 741 823 indicator 01 MY-DBCLOB-LOCATOR USAGE IS SQL TYPE IS DBCLOB-LOCATOR. 01 MY-DBCLOB-FILE USAGE IS SQL TYPE IS DBCLOB-FILE. Identifies DBCLOB entities residing on the server Descriptor for file containing DBCLOB data
The following are additional rules for supported COBOL data types:
y
You can use level number 77 instead of 01 for all column types except VARCHAR, LONG VARCHAR, VARGRAPHIC, LONG VARGRAPHIC and all LOB variable types. Use the following rules when declaring host variables for DECIMAL(p,s) column types. See the following sample:
01 identifier PIC S9(m)V9(n) COMP-3 o o o o o o o o o
Use V to denote the decimal point. Values for n and m must be greater than or equal to 1. The value for n + m cannot exceed 31. The value for s equals the value for n. The value for p equals the value for n + m. The repetition factors (n) and (m) are optional. The following examples are all valid:
01 01 01 01 identifier identifier identifier identifier PIC PIC PIC PIC S9(3)V COMP-3 SV9(3) COMP-3 S9V COMP-3 SV9 COMP-3
PACKED-DECIMAL can be used instead of COMP-3. Arrays are not supported by the COBOL precompiler.
o
Related concepts
y y y y y
Host variable names in COBOL Declare section for host variables in COBOL embedded SQL applications Null-indicator variables and null or truncation indicator variable tables in COBOL embedded SQL applications Example: SQL declare section template for COBOL embedded SQL applications Example: Referencing XML host variables in embedded SQL applications
Related tasks
y y
Executing XQuery expressions in embedded SQL applications Declaring XML host variables in embedded SQL applications
Related reference
y
Feedback