Typically, based on its knowledge of a column in the result set (via SQLDescribeCol() or prior knowledge), the application may choose to allocate the maximum memory the column value could occupy and bind it via SQLBindCol(). However, in the case of character and binary data, the column can be arbitrarily long. If the length of the column value exceeds the length of the buffer the application can allocate or afford to allocate, a feature of SQLGetData() lets the application use repeated calls to obtain in sequence the value of a single column in more manageable pieces.
Basically, as shown on the left side of Figure 9, a call to SQLGetData() returns SQL_SUCCESS_WITH_INFO (with SQLSTATE 01004) to indicate more data exists for this column. SQLGetData() is called repeatedly to get the remaining pieces of data until it returns SQL_SUCCESS, signifying that the entire data have been retrieved for this column.
The function SQLGetSubString() can also be used to retrieve a specific portion of a large object value. See SQLGetSubString - Retrieve Portion of A String Value for more information. For other alternative methods to retrieve long data, refer to "Using Large Objects".
Figure 9. Piecewise Input and Retrieval
![]() |