executeStoredProcedure()

Executes an SQL stored procedure by specifying its name and parameter array.

Syntax

void executeStoredProcedure(String storedProcedure, 
                   Vector storedProcParameters)
 

Parameters

storedProcedure
The name of the SQL stored procedure to execute in the database.

storedProcParameters
A Vector object of parameters to pass to the stored procedure. Each parameter is an instance of the CwDBStoredProcedureParam class. For more information on how to pass parameters through this array, see

Return values

None.

Exceptions

CwDBSQLException - If a database error occurs.

Notes

The executeStoredProcedure() method sends a call to the specified storedProcedure to the database associated with the current connection. This method sends the stored-procedure call as a prepared SQL statement; that is, the first time it executes, this stored-procedure call is sent as a string to the database, which compiles the string into an executable form (called a prepared statement), executes the SQL statement, and returns this prepared statement to executeStoredProcedure(). The executeStoredProcedure() method saves this prepared statement in memory.

Important:
Before executing a stored procedure with executeStoredProcedure(), you must create a CwDBConnection object with the getDBConnection() method from the BaseDLM class.

To handle any data that the stored procedure returns, use the hasMoreRows() and nextRow() methods.

You can also use the executeSQL() or executePreparedSQL() method to execute a stored procedure as long as this stored procedure does not contain OUT parameters. If the stored procedure uses OUT parameters, you must use executeStoredProcedure() to execute it. Unlike with executeSQL() or executePreparedSQL(), you do not have to pass in the full SQL statement to execute the stored procedure. With executeStoredProcedure(), you need to pass in only the name of the stored procedure and a Vector parameter array of CwDBStoredProcedureParam objects. The executeStoredProcedure() method can determine the number of parameters from the storedProcParameters array and builds the calling statement for the stored procedure.

See also

executePreparedSQL(), executeSQL(), getDBConnection(), hasMoreRows(), nextRow()

Copyright IBM Corp. 1997, 2003