Executes a prepared dynamic SQL statement.
ANSI Compliance
The dynamic SQL form of EXECUTE is ANSI/ISO SQL:2011-compliant.
Required Privileges
The privileges required depend on the SQL statement and tables accessed.
Invocation
Executable.
Dynamic SQL statement.
Embedded SQL only.
Syntax
EXECUTE statement_name [ USING using_spec [,...] | USING DESCRIPTOR [:] descriptor_area ]
Syntax Elements
- using_spec
[:] host_variable_name [ [INDICATOR] :host_indicator_name ]
- statement_name
- The name associated with the previously prepared statement.
- host_variable_name
- The variable used as input data for the prepared statement.
- host_indicator_name
- The indicator variable.
- descriptor_area
- An SQL Descriptor Area (SQLDA).
Usage Notes
- General Rules
An SQLDA should be defined for the application.
The statement specified by statement_name must have been previously prepared successfully within the same transaction.
EXECUTE cannot be used with a dynamic:- Data returning statement
- Macro
- Multistatement request
For these cases, a dynamic cursor must be declared and the application program should access the results using an appropriate FETCH statement.
EXECUTE itself cannot be executed as a dynamic SQL statement.
- USING Clause Rules
- The USING clause identifies variables used as input to the SQL statement specified by statement_name.
- The specified host variable name must be a valid client language variable declared prior to the EXECUTE statement that will be used as an input variable. A client structure can be used to identify the input variables.
The number of variables specified must be the same as the number of parameter markers (the QUESTION MARK character) in the identified statement. The nth variable must correspond to the nth parameter marker.
- The descriptor name identifies an input SQLDA structure previously defined by the application. This SQLDA contains all necessary information about the input variable set.
The number of variables identified by the SQLD field of the SQLDA must be the same as the number of parameter markers (the QUESTION MARK character) in the identified statement. The nth variable described by the SQLDA must correspond to the nth parameter marker.
Related Information
- DESCRIBE
- EXECUTE IMMEDIATE
- PREPARE (Dynamic)
- descriptor_area, see Teradata® Preprocessor2 for Embedded SQL Programmer Guide, B035-2446.
- FETCH statement, see FETCH (Embedded SQL Form)