Updated on 2025-06-30 GMT+08:00

ODBC API Reference

Obtaining Parameter Description

SQLDescribeParam is a function in the ODBC API. It is used to obtain the description of parameters related to prepared SQL statements (for example, calling SQLPrepare). It can return metadata such as the type, size, and whether NULL values are allowed for parameters, which is useful for dynamically building SQL statements and binding parameters.

Prototype

SQLRETURN SQLDescribeParam(  
      SQLHSTMT        StatementHandle,  
      SQLUSMALLINT    ParameterNumber,  
      SQLSMALLINT    *DataTypePtr,  
      SQLULEN        *ParameterSizePtr,  
      SQLSMALLINT    *DecimalDigitsPtr,  
      SQLSMALLINT    *NullablePtr);
Table 1 Parameters of SQLDescribeParam

Parameter

Description

Difference

StatementHandle

Statement handle.

-

ParameterNumber

Parameter marker number, starting with 1 and increasing in ascending order.

-

DataTypePtr

Points to the data type of the returned parameter.

In MySQL, ODBC returns SQL_VARCHAR for any type.

In GaussDB, ODBC returns the data type to an application based on that returned by the kernel.

ParameterSizePtr

Points to the size of the returned parameter.

If MySQL allows the ODBC driver to use a larger data packet for data transmission, 24M is returned. Otherwise, 255 is returned.

In GaussDB, ODBC returns the parameter size based on the actual type.

DecimalDigitsPtr

Points to the number of decimal digits of the returned parameter.

-

NullablePtr

Points to whether NULL values are allowed for the returned parameter.

In MySQL, ODBC directly returns SQL_NULLABLE_UNKNOWN.

In GaussDB, ODBC directly returns SQL_NULLABLE.