Executes a prepared SQL query by specifying its syntax.
The Execute Prepared SQL function block can throw the CwDBSQLException exception if a database error occurs.
The SQL statements you can execute include the following (as long as you have the necessary database permissions):
Use the Has More Rows and Next Row function blocks to access the retrieved data.
The Execute Prepared SQL function block 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 the function block. The function block then saves this prepared statement in memory. Use Execute Prepared SQL for SQL statements that you need to execute multiple times.
Before executing a query with Execute Prepared SQL, you must obtain a connection to the desired database by generating a CwDBConnection object with the Get Database Connection function block.
If the connection uses explicit transaction bracketing, you must explicitly start each transaction with Begin Transaction and end it with either Commit or Roll Back.
To execute stored procedures with OUT parameters, use the Execute Stored Procedure function block. For more information, see Calling stored procedures with executeStoredProcedure().
This function block is based on the CwDBConnection.executePreparedSQL() method. For more information, see executePreparedSQL().