EXECUTE | Teradata Vantage - EXECUTE (Dynamic SQL Form) - Advanced SQL Engine - Teradata Database

SQL Stored Procedures and Embedded SQL

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
17.00
Published
June 2020
Language
English (United States)
Last Update
2021-01-23
dita:mapPath
xqq1557098602407.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1148
lifecycle
previous
Product Category
Teradata Vantage™

Purpose

Executes a prepared dynamic SQL statement.

Invocation

Executable.

Dynamic SQL statement.

Embedded SQL only.

Syntax

EXECUTE statement_name
  [ USING using_spec [,...] |
    USING DESCRIPTOR [:] descriptor_area
  ]
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.
The colon preceding the name or names is optional.
host_indicator_name
The indicator variable.
The colon preceding the name is mandatory.
descriptor_area
An SQL Descriptor Area (SQLDA).
You can code descriptor_area as a name or as a pointer reference (*sqldaname) in C programs when the SQLDA structure is declared as a pointer.

ANSI Compliance

The dynamic SQL form of EXECUTE is ANSI/ISO SQL:2011-compliant.

Authorization

The privileges required depend on the SQL statement and tables accessed.

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 n th variable must correspond to the n th 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 n th variable described by the SQLDA must correspond to the n th parameter marker.

Related Topics

See the following statements for further information: