Retrieving LOB Data - ODBC Driver for Teradata

ODBC Driver for Teradata® User Guide - 17.20

Deployment
VantageCloud
VantageCore
Edition
VMware
Enterprise
IntelliFlex
Lake
Product
ODBC Driver for Teradata
Release Number
17.20
Publication Date
June 2022
Content Type
User Guide
Publication ID
B035-2526-062K
ft:locale
en-US
ft:lastEdition
2026-02-20
dita:mapPath
uqj1639470627591.ditamap
dita:ditavalPath
nkw1500504256726.ditaval
ft:sourceId
dita
dita:id
ktb1507075385726
Product Category
Teradata Tools and Utilities

LOB data should be retrieved using SQLGetData to retrieve and process LOB data in parts. The following code fragment illustrates that. Note the loop to handle 2 BLOB column.

SQLINTEGER   id;
SQLCHAR      image[IMAGEPART_LEN ];
SQLINTEGER   cbid = 0;
SQLUINTEGER  cbimage = 0;
SQLRETURN    retcode;

retcode = SQLExecDirect(hstmt, (SQLCHAR*)"select id, image from blobtable", SQL_NTS);

while (retcode == SQL_SUCCESS ) {
    retcode = SQLFetch(hstmt);
    if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO){

        /* Get data for column 1 */
        SQLGetData(hstmt, 1, SQL_C_ULONG, &id, 0, &cbid);

        /* Get data for column 2 */
        while (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO )
        {
            retcode= SQLGetData(hstmt, 2, SQL_C_CHAR, image, IMAGEPART_LEN,&cbimage);
            switch (retcode)
            {
            case SQL_SUCCESS_WITH_INFO:
            case SQL_SUCCESS:
                processimage(id, image);
                break;
            case SQL_NO_DATA:
                break;
            case SQL_ERROR:
            default:
                processerror(retcode);
                break;
            }
        }
    }