in src/odbc/rsodbc/rsresult.cpp [624:710]
SQLRETURN SQL_API RS_STMT_INFO::RS_SQLGetData(RS_STMT_INFO *pStmt,
SQLUSMALLINT hCol,
SQLSMALLINT hType,
SQLPOINTER pValue,
SQLLEN cbLen,
SQLLEN *pcbLenInd,
int iInternal)
{
SQLRETURN rc = SQL_SUCCESS;
RS_RESULT_INFO *pResult = pStmt->pResultHead;
if(pcbLenInd)
*pcbLenInd = 0L;
if(pResult)
{
if(pResult->iNumberOfCols && pStmt->pIRD->pDescRecHead)
{
if(!iInternal && (hCol == pResult->iPrevhCol))
{
rc = SQL_NO_DATA;
goto error;
}
if(hCol > 0 && hCol <= pResult->iNumberOfCols)
{
int iDataLen;
int format;
char *pData = libpqGetData(pResult, hCol - 1, &iDataLen, &format);
RS_DESC_REC *pDescRec = &pStmt->pIRD->pDescRecHead[hCol - 1];
if(pcbLenInd)
{
*pcbLenInd = 0;
*pcbLenInd = iDataLen;
}
if (pValue && pData && (iDataLen != SQL_NULL_DATA)) {
rc = convertSQLDataToCData(
pStmt, pData, iDataLen, pDescRec->hType, pValue, cbLen,
&(pResult->getColumnReadOffset(hCol)), pcbLenInd, hType,
pDescRec->hRsSpecialType, format, pDescRec);
} else if (iDataLen == SQL_NULL_DATA) {
if (pValue && (cbLen > 0)) *(char *)pValue = '\0';
if(!pcbLenInd)
{
rc = SQL_ERROR;
addError(&pStmt->pErrorList,"22002", "Indicator variable required but not supplied", 0, NULL);
goto error;
}
else
*pcbLenInd = SQL_NULL_DATA;
}
if(!iInternal && (rc != SQL_SUCCESS_WITH_INFO))
pResult->iPrevhCol = hCol;
}
else
{
rc = SQL_ERROR;
addError(&pStmt->pErrorList,"HY000", "SQLGetData: Invalid column number", 0, NULL);
goto error;
}
}
else
{
rc = SQL_ERROR;
addError(&pStmt->pErrorList,"HY000", "No columns found", 0, NULL);
goto error;
}
}
else
{
rc = SQL_ERROR;
addError(&pStmt->pErrorList,"HY000", "No result found", 0, NULL);
goto error;
}
error:
if(pResult && !iInternal && (rc == SQL_ERROR))
pResult->iPrevhCol = hCol;
return rc;
}