Fixed-length binary data types (RAW, BINARY, and CHAR(x) FOR BIT DATA) are SQL data types with a driver-defined maximum length.
Host Variable Formats
- OpenESQL
-
03 bin-field1 PIC X(5).
03 bin-field2 SQL TYPE IS BINARY(200).
- SQL BINARY, VARBINARY and IMAGE data are represented in COBOL as PIC X (n) fields.
- OpenESQL does not perform data conversion.
- When data is fetched from the database, if the host-variable field is smaller than the amount of data fetched, the data is
truncated and the SQLWARN1 field in the SQLCA data structure is set to
W. If the host-variable field is larger than the amount of data, the field is padded with null (x"00") bytes.
- Any of the following enable you to insert data into BINARY, VARBINARY or LONG-VARBINARY columns:
- Use dynamic SQL statements
- Compile your application with the ALLOWNULLCHAR directive
- Use SQL TYPE host variables
- If you use PIC X host variables, compile your application with the ALLOWNULLCHAR directive to prevent the truncation of transferred
data to or from the host variable if a null (x"00") is encountered.
- The
bin-field2 format uses the BINARY SQL TYPE.
- DB2 ECM
-
03 bin-field1 PIC X(5).
- Use CHAR FOR BIT DATA to represent BINARY.
- Use VARCHAR(n) FOR BIT DATA to represent VARBINARY.
- Use LONG VARCHAR FOR BIT DATA to represent LONG-VARBINARY.
- The IBM ODBC driver returns the BINARY, VARBINARY and LONG VARBINARY data types instead of the IBM equivalent.
- The IMAGE data type can be represented by BLOB.
- DB2 uses LOBs (Character Large Object, Binary Large Object or Graphical Large Object) to define very large columns (2 Gigabytes
maximum). You can use static SQL with these data types.