LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

excute a dtored procedure with sql toolkit

how I can excute a stored procedure  with sql toolkit
0 Kudos
Message 1 of 2
(3,061 Views)

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.

Example

/* 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( ).

With warm regards,

David D.
0 Kudos
Message 2 of 2
(3,033 Views)