The prepared statement identified by the statement name is executed.
If the source form of the prepared statement contains parameter markers, the EXECUTE statement must be used with the USING clause to correctly associate the statement parameters with the allocated SQL descriptor area or an appropriate number of host variables.
Use INTO for a singleton SELECT statement where the result set consists of only one row. For example: SELECT COUNT(*)
The DESCRIBE INPUT statement can be used to determine the PARAMETER_MODE of each of the parameters in the prepared statement.
If parameter markers are present, the USING clause must be used to specify an SQL descriptor area or a list of host variables for these parameters. There must be one variable in the host variables list or ‘referenced’ in the SQL descriptor area for each parameter in the prepared statement. The variables are associated with the parameter markers in a left to right manner as they appear in the prepared statement.
The data types of the variables must be compatible with their usage in the source statement.
The descriptor-name is identified by a host variable or a literal.
See ALLOCATE CURSOR for a description of extended statements.
For a fuller discussion of the use of EXECUTE statements in dynamic application programs, see the Mimer SQL Programmer's Manual, Dynamic SQL.
The EXECUTE statement may only be used for dynamically prepared statements.
Dynamically prepared SELECT statements and calls to result set procedures may not be executed. These should be performed using a sequence of OPEN, FETCH and CLOSE statements, i.e. using a cursor.
Note:You can use singleton SELECT statements or calls to result set procedures if the result set will contain only one row.
See the Mimer SQL Programmer's Manual, Communicating with the Application Program for information on the format of the host variable.
exec sql PREPARE 'stmt 1' FROM :sqlstr;
exec sql ALLOCATE DESCRIPTOR 'DescrIn';
exec sql DESCRIBE INPUT 'stmt 1' USING SQL DESCRIPTOR 'DescrIn';
exec sql EXECUTE 'stmt 1' USING SQL DESCRIPTOR 'DescrIn';
For more information, see the Mimer SQL Programmer's Manual, Executable Statements.
Features outside core
Feature B031, “Basic dynamic SQL”.