MDAC 2.5 SDK - ODBC Programmer's Reference
Chapter 9: Executing Statements


 

Retrieving Output Parameters by SQLGetData

An application can retrieve bound output parameters by calling SQLBindParameter, in which case output values are present in the application variables to which the respective parameters are bound. If the output parameters are unbound, the application can read argument values by calling SQLGetData. The application can use both of these techniques if some parameters are bound and some are unbound.

For unbound output parameters following the highest-numbered bound parameter, portable applications obtain the parameter data by calling SQLGetData in ascending order of parameter number. It is driver-defined whether an application can obtain parameter data in a different sequence. It is driver-defined whether parameter data for lower-numbered unbound parameters is available.

The application can achieve type conversion of the parameter data by specifying in the call to SQLGetData either the desired target type or the value SQL_APD_TYPE, which means that the APD indicates the desired target type even though the parameter is unbound.

If the length of the unbound output parameter value exceeds the length of the application's buffer, SQLGetData can be called multiple times to obtain the value of a single parameter of SQL_CHAR or SQL_VARCHAR type in pieces of manageable size.