solidDB Help : Programming : solidDB ODBC API : Using cursors : Assigning storage for rowsets (binding)
  
Assigning storage for rowsets (binding)
In addition to binding individual rows of data, an application can call SQLBindCol() to assign storage for a rowset (one or more rows of data). By default, rowsets are bound in column-wise fashion but they can also be bound in row-wise fashion.
To specify how many rows of data are in a rowset, an application calls SQLSetStmtAttr() with the SQL_ROWSET_SIZE option.
Column-wise binding
To assign storage for column-wise bound results, an application performs the following steps for each column to be bound:
1 Allocates an array of data storage buffers. The array has as many elements as there are rows in the rowset.
2 Allocates an array of storage buffers to hold the number of bytes available to return for each data value. The array has as many elements as there are rows in the rowset.
3 Calls SQLBindCol() and specifies the address of the data array, the size of one element of the data array, the address of the number-of-bytes array, and the type to which the data will be converted. When data is retrieved, the driver uses the array element size to determine where to store successive rows of data in the array.
Row-wise binding
To assign storage for row-wise bound results, an application performs the following steps:
1 Declares a structure that can hold a single row of retrieved data and the associated data lengths. For each column to be bound, the structure contains one field to contain data and one field to contain the number of bytes of data available to return.
2 Allocates an array of these structures. This array has as many elements as there are rows in the rowset.
3 Calls SQLBindCol() for each column to be bound. In each call, the application specifies the address of the column data field in the first array element, the size of the data field, the address of the column number-of-bytes field in the first array element, and the type to which the data will be converted.
4 Calls SQLSetStmtAttr() with the SQL_BIND_TYPE option and specifies the size of the structure. When the data is retrieved, the driver uses the structure size to determine where to store successive rows of data in the array.
Go up to
Using cursors