02-26-2009 02:06 AM
02-27-2009 01:25 PM
Hello,
You can use DBExecutePreparedSQL( ), here is the function help which includes some example code:
"Executes a stored procedure or SQL statement that you have prepared with DBPrepareSQL.
/* Create a stored procedure. */
resCode = DBImmediateSQL (hdbc, "create proc sp_CVITest(
@InParam int, @OutParam int OUTPUT ) as \
select @OutParam = @InParam + 10 SELECT * FROM \
Authors WHERE State <> 'CA' return @OutParam +10");
/* Prepare a statement that calls the stored procedure. */
resCode = DBSetAttributeDefault (hdbc, ATTR_DB_COMMAND_TYPE,
DB_COMMAND_STORED_PROC);
hstmt = DBPrepareSQL (hdbc, "sp_Adotest");
resCode = DBSetAttributeDefault (hdbc, ATTR_DB_COMMAND_TYPE,
DB_COMMAND_UNKNOWN);
/* Refresh the parameters from the stored procedure. */
resCode = DBRefreshParams (hstmt);
/* Set the input parameter. */
resCode = DBSetParamShort (hstmt, 2, 10);
/* Execute the statement. */
resCode = DBExecutePreparedSQL (hstmt);
while ((resCode = DBFetchNext (hstmt)) == DB_SUCCESS) {
/* Process records returned by the stored procedure. */
}
/* Close the statement. Output parameters are invalid */
/* until you close the statement. */
resCode = DBClosePreparedSQL (hstmt);
/* Examine the parameter values. */
resCode = DBGetParamShort (hstmt, 1, &retParam);
resCode = DBGetParamShort (hstmt, 2, &inParam);
resCode = DBGetParamShort (hstmt, 3, &outParam);
/* Discard the statement. */
hstmt = DBDiscardSQLStatement (hstmt);
Prototype
int DBExecutePreparedSQL (int Statement_Handle);"
Additionally, if you would like to use parameters you must first call PrepareSQLStatement( ).