An application can assign storage for results before or after it executes an SQL statement. If an application prepares or executes the SQL statement first, it can inquire about the result set before it assigns storage for results. For example, if the result set is unknown, the application must retrieve the number of columns before it can assign storage for them.
To associate storage for a column of data, an application calls SQLBindCol and passes it the following information:
The application must allocate this buffer, and it must be large enough to hold the data in the form to which it is converted.
This value is ignored if the returned data has a fixed width in C, such as an integer, real number, or date structure.
An application can also bind result set columns to arrays of program variables to support fetching result set rows in blocks. There are two different types of array binding:
Column-wise binding is specified by calling SQLSetStmtAttr with Attribute set to SQL_ATTR_ROW_BIND_TYPE and ValuePtr set to SQL_BIND_BY_COLUMN. All of the arrays must have the same number of elements.
Row-wise binding is specified by calling SQLSetStmtAttr with Attribute set to SQL_ATTR_ROW_BIND_TYPE and ValuePtr set to the size of the structure holding the variables that will receive the result set columns.
The application also sets SQL_ATTR_ROW_ARRAY_SIZE to the number of elements in the column or row arrays, and sets SQL_ATTR_ROW_STATUS_PTR and SQL_ATTR_ROWS_FETCHED_PTR.
To process results
SQLBindCol | SQLSetStmtAttr |