Enterprise Edition Home | Express Edition Home | Previous Page | Next Page   SQL Statements >

EXECUTE

Use the EXECUTE statement to run a previously prepared statement or a multiple-statement prepared object.

Only Dynamic Server supports this statement. Use this statement with ESQL/C.

Syntax

Read syntax diagramSkip visual syntax diagram>>-EXECUTE--+-stmt_id-----+--+----------------------+----------->
            '-stmt_id_var-'  |                 (1)  |
                             '-| INTO Clause |------'
 
>--+-----------------------+-----------------------------------><
   |                  (2)  |
   '-| USING Clause |------'
 
Notes:
  1. See INTO Clause
  2. See USING Clause
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

Usage

The EXECUTE statement passes a prepared SQL statement to the database server for execution. The following example shows an EXECUTE statement within an ESQL/C program:

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.

You can execute any prepared statement except those in the following list:

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.

Enterprise Edition Home | Express Edition Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]