EXECUTE statement
Use the EXECUTE statement to run a previously prepared statement or a multiple-statement prepared object.
Use this statement with Informix® ESQL/C.
Syntax
Element | Description | Restrictions | Syntax |
---|---|---|---|
stmt_id | Identifier of a prepared SQL statement | Must have been declared in a previous PREPARE statement | Identifier |
stmt_id_var | Host variable containing the identifier of a prepared statement | Must exist and must contain a statement identifier that a previous PREPARE statement declared, and must be of a character data type | PREPARE statement |
Usage
EXEC SQL PREPARE del_1 FROM
'DELETE FROM customer WHERE customer_num = 119';
EXEC SQL EXECUTE del_1;
Once prepared, an SQL statement can be executed as often as needed.
After you release the database server resources (using a FREE statement), you cannot use the statement identifier with a DECLARE cursor or with the EXECUTE statement until you prepare the statement again.
If the statement contained question mark ( ? ) placeholders, use the USING clause to provide specific values for them before execution. For more information, see the USING Clause.
- A prepared SELECT statement that returns more than one row
When you use a prepared SELECT statement to return multiple rows of data, you must use a cursor to retrieve the data rows. As an alternative, you can EXECUTE a prepared SELECT INTO TEMP statement to achieve the same result.
For more information on cursors, see DECLARE statement.
- A prepared EXECUTE FUNCTION (or EXECUTE PROCEDURE) statement for an SPL function that returns
more than one row
When you prepare an EXECUTE FUNCTION (or EXECUTE PROCEDURE) statement to invoke an SPL function that returns multiple rows, you must use a cursor to retrieve the data rows.
For more information on how to execute a SELECT or an EXECUTE FUNCTION (or EXECUTE PROCEDURE) statement, see PREPARE statement.
If you create or drop a trigger after you prepare a triggering INSERT, DELETE, or UPDATE statement, the prepared statement returns an error when you execute it.