IBM Books

Call Level Interface Guide and Reference

Length

The length of a column is the maximum number of bytes returned to the application when data is transferred to its default C data type. For character data, the length does not include the null termination byte. Note that the length of a column may be different than the number of bytes required to store the data on the data source. For a list of default C data types, see the "Default C Data Types" section.

The following table defines the length for each SQL data type.

Table 199. Length
fSqlType 

Length 

SQL_CHAR 
SQL_VARCHAR
SQL_CLOB

The defined length of the column. For example, the length of a column defined as CHAR(10) is 10.
SQL_LONGVARCHAR 

The maximum length of the column.

SQL_DECIMAL 
SQL_NUMERIC

The maximum number of digits plus two. Since these data types are returned as character strings, characters are needed for the digits, a sign, and a decimal point. For example, the length of a column defined as NUMERIC(10,3) is 12.
SQL_SMALLINT 

2 (two bytes).
SQL_INTEGER
4 (four bytes).

SQL_REAL 

4 (four bytes).

SQL_FLOAT 

8 (eight bytes).

SQL_DOUBLE 

8 (eight bytes).

SQL_BINARY 
SQL_VARBINARY
SQL_BLOB

The defined length of the column. For example, the length of a column defined as CHAR(10) FOR BIT DATA is 10.
SQL_LONGVARBINARY 

The maximum length of the column.
SQL_DATE 
SQL_TIME

6 (the size of the DATE_STRUCT or TIME_STRUCT structure).
SQL_TIMESTAMP 

16 (the size of the TIMESTAMP_STRUCT structure).
SQL_GRAPHIC 
SQL_VARGRAPHIC
SQL_DBCLOB

The defined length of the column times 2. For example, the length of a column defined as GRAPHIC(10) is 20.
SQL_LONGVARGRAPHIC 

The maximum length of the column times 2.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]

[ DB2 List of Books | Search the DB2 Books ]