DB_ExecuteSql Function

Action

Sends an SQL statement to the specified database for execution.

Syntax

hstmnt = DB_ExecuteSql (hdbc, sql_stmnt)
Variable Description
hstmnt

The returned handle to the executed SQL statement. This is an input parameter for other DBTester functions, for example DB_FetchNext. HSQL.

hdbc

The handle to a database as returned by DB_Connect. HDATABASE.

sql_stmnt

The SQL statement to be executed. STRING.

To call a stored procedure using MS SQL, use:

execute Procedure_Name

To call a stored procedure using Oracle, use:

begin; Procedure_Name; end;

Notes

Use the DB_Fetch functions to retrieve the results of a Select statement. You must use DB_FinishSql to release the resource when you no longer need the statement handle for the DB_Fetch functions.

Examples

The following example uses a Select statement:

hstmnt = DB_ExecuteSql (hdbc, "SELECT * FROM emp")

The following example calls a stored procedure using MS SQL:

hdbc = DB_Connect (connectURL)
hstmnt = DB_ExecuteSql (hdbc, "execute claimgen.generateclaim('Sandra',SYSDATE)")

The following example calls a stored procedure using Oracle:

hdbc = DB_Connect (connectURL)
hstmnt = DB_ExecuteSql (hdbc,"begin claimgen.generateclaim('Sandra',SYSDATE); COMMIT; end;")