executePreparedSQL()

Executes a prepared SQL query by specifying its syntax and an optional parameter array.

Syntax

void executePreparedSQL(String query)
 void executePreparedSQL(String query, Vector queryParameters)
 

Parameters

query
A string representation of the SQL query to execute in the database.
queryParameters
A Vector object of arguments to pass to parameters in the SQL query.

Return values

None.

Exceptions

CwDBSQLException - If a database error occurs.

Notes

The executePreparedSQL() method sends the specified query string as a prepared SQL statement to the database associated with the current connection. The first time it executes, this query 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 executePreparedSQL(). The executePreparedSQL() method saves this prepared statement in memory. Use executePreparedSQL() for SQL statements that you need to execute multiple times. The executeSQL() method does not save the prepared statement and is therefore useful for queries you need to execute only once.

Important:
Before executing a query with executePreparedSQL(), you must obtain a connection to the desired database by generating a CwDBConnection object with the getDBConnection() method from the BaseDLM class.

The SQL statements you can execute include the following (as long as you have the necessary database permissions):

See also

beginTransaction(), commit(), executeSQL(), executeStoredProcedure(), getDBConnection(), hasMoreRows(), nextRow(), rollBack()

Copyright IBM Corp. 2003