skip to main content
Implementing SQL pass-through mode : Selective SQL pass-through : Sample code
 

Sample code

The IP should return 1 from GETSUPPORT (IP_SUPPORT_QUERY_MODE_SELECTION).
int OAIP_execute(IP_HDBC hdbc,
DAM_HSTMT hstmt,
int iStmtType,
DAM_HCOL hSearchCol,
int *piNumResRows)
{
Uint16 iValue;
int iValueLen;
int iRetCode;
if (iStmtType == DAM_SET_QUERY_MODE) {
/* check query using Pass-Through API */
if (xxx_query_pass_through_compatible(damex_getQuery(hstmt))
iRetCode = dam_setOption(DAM_STMT_OPTION, hstmt,
DAM_STMT_OPTION_PASSTHROUGH_QUERY, DAM_PROCESSING_ON);
}
return DAM_SUCCESS;
}
/* for all other operations check query execution mode */
iRetCode = dam_getInfo(NULL, hstmt, DAM_INFO_PASSTHROUGH_QUERY,
(void *)&iValue, sizeof(iValue), &iValueLen);
tm_trace(db3_tm_Handle, UL_TM_MINOR_EV, "Pass-Through Mode:<%d>\n",
(iValue));
if (iValue) {
iRetCode = xxx_ip_execute_passthrough(hdbc, hstmt, iStmtType,
hSearchCol, piNumResRows);
}
else {
iRetCode = xxx_ip_execute_normal(hdbc, hstmt, iStmtType, hSearchCol,
piNumResRows);
}
return iRetCode;
}