Setting Parameter Values
If a length/indicator buffer was bound in the call to SQLBindParameter, it must be set to one of the following values before the statement is
executed:
The following table shows the values of the bound variable and the
length/indicator buffer that the application sets for a variety of parameter values.
The byte length of the data in the bound variable. The driver checks this
length only if the variable is character or binary (ValueType is SQL_C_CHAR or SQL_C_BINARY).
SQL_NTS. The data is a null-terminated string.
SQL_NULL_DATA. The data value is NULL and the driver ignores the value of the
bound variable.
SQL_DATA_AT_EXEC or the result of the SQL_LEN_DATA_AT_EXEC macro. The value of
the parameter is to be sent with SQLPutData. For more information, see
Parameter
value | Parameter (SQL)
data type | Variable (C)
data type | Value in bound
variable | Value in length/
indicator buffer [d] |
“ABC” | SQL_CHAR
| SQL_C_CHAR
| ABC\0 [a]
| SQL_NTS or 3
|
10
| SQL_INTEGER
| SQL_C_SLONG
| 10
| --
|
10
| SQL_INTEGER
| SQL_C_CHAR
| 10\0 [a]
| SQL_NTS or 2
|
1 P.M.
| SQL_TYPE_TIME
| SQL_C_TYPE_
TIME | 13,0,0 [b]
| --
|
1 P.M.
| SQL_TYPE_TIME
| SQL_C_CHAR
| {t '13:00:00'}\0
[a], [c] | SQL_NTS or 14
|
NULL
| SQL_SMALLINT
| SQL_C_SSHORT
| --
| SQL_NULL_DATA
|
[a] “\0” represents a null-termination character. The null-termination character is required only if the value in the length/indicator buffer is SQL_NTS. [b] The numbers in this list are the numbers stored in the fields of the TIME_STRUCT structure. [c] The string uses the ODBC date escape clause. For more information, see “Date, Time, and Timestamp Literals” in Chapter 8, “SQL Statements.” [d] Drivers must always check this value to see if it is a special value such as SQL_NULL_DATA. |
|
|
|