Specifying the data type

To override the default behavior and to explicitly specify the data type, a data type indicator must precede the bind value. The syntax for this is:

:bind([T|N],value)

The following table lists the data type indicators and the relationship between each data type indicator and the DB2® data types.

Data Type Indicator
DB2 Data Type
T or TEXT
Any non-numeric (including DATE, TIME, and TIMESTAMP)
N or NUM or NUMBER
Any numeric (INT, DECIMAL, REAL, and so on)

As an example of specifying a data type, to bind a value that is a text data type containing only digits to a statement, the SQL statement would be entered as:

DBLOOKUP ("Select * from Checks where CheckNumber=:bind([TEXT]," +
CheckNumber:Row +")",
"DB.mdq",
"MyDB")

If the [TEXT] data type indicator is not specified, the trace file from the adapter displays the following error message:

Message: [IBM] [CLI Driver] [DB2/NT]SQL0301N
The value of a host variable in the EXECUTE or OPEN 
statement cannot be used because of its data type.
SQLSTATE=07006.