/*
Example 1: How to call a stored procedure and use input and output parameters*/
SQLBindParameter(stmt, 1, SQL_PARAM_OUTPUT, SQL_C_SLONG,
SQL_INTEGER, 0, 0, &retVal, 0, SQL_NULL_HANDLE);
SQLBindParameter(stmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR,
SQL_CHAR, 4, 0, stor_id, sizeof(stor_id), SQL_NULL_HANDLE);
SQLBindParameter(stmt, 3, SQL_PARAM_OUTPUT, SQL_C_CHAR,
SQL_VARCHAR, 20, 0, ord_num, sizeof(ord_num), &ordnumLen);
SQLBindParameter(stmt, 4, SQL_PARAM_INPUT, SQL_C_CHAR,
SQL_VARCHAR, 40, 0, date, sizeof(date), &dateLen);
SQLExecDirect( stmt, "{ ? = call sp_selectsales(?,?,?) }", SQL_NTS);
/*
At this point retVal contains the return value as returned from
the stored
procedure and the ord_num contains the order number as returned from the stored procedure
*/
/*
Example 2: How to call stored procedures returning multiple result sets
*/
SQLBindParameter(stmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR,
SQL_CHAR , 4, 0, stor_id, sizeof(stor_id), SQL_NULL_HANDLE);
SQLExecDirect(stmt, "{ call sp_multipleresults(?) }", SQL_NTS);
SQLBindCol( stmt, 1, SQL_C_CHAR, dbValue, sizeof(dbValue), &dbValueLen);
SQLSMALLINT count = 1;
while(retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
{
retcode = SQLFetch( stmt );
if (retcode == SQL_NO_DATA)
{
/*
-- End of first result set --
*/
if(count == 1)
{
retcode = SQLMoreResults(stmt);
count ++;
}
/*
At this point dbValue contains the value in the current row of the
result
*/
}
}