EXECUTE Statement | SQL Statements | Teradata Vantage - EXECUTE (Macro Form) - Analytics Database - Teradata Vantage

SQL Data Manipulation Language

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
Language
English (United States)
Last Update
2024-04-05
dita:mapPath
pon1628111750298.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
esx1472246586715
lifecycle
latest
Product Category
Teradata Vantage™

Performs a macro.

For information about the embedded SQL EXEC statement, which is used to run macros from embedded SQL applications, see Teradata Vantage™ - SQL Stored Procedures and Embedded SQL, B035-1148.

ANSI Compliance

EXECUTE is a Teradata extension to the ANSI SQL:2011 standard.

Required Privileges

You must have EXECUTE privilege on the macro. The creator or any owner of the macro can grant the EXECUTE privilege to another. In addition, the immediate owner of the macro (the database in which the macro resides) must have the necessary privileges on objects named in the request set that are contained in the macro.

For more information, see Teradata Vantage™ - SQL Data Definition Language Detailed Topics, B035-1184 and Teradata Vantage™ - Database Administration, B035-1093.

Recommendation

A data definition request in a macro is not fully resolved until the macro is submitted for execution. Unqualified references to database objects are resolved at that time using the default database of the executing user.

Because of this, object references in data definition statements should always be fully qualified (as databasename.tablename) in the body of the macro.

Rules for Performing Macros

The following rules apply to performing macros.
  • The number of commas must match the macro definition if you do not use the parameter_name syntax.
  • Any value in the EXECUTE constant expression list form without a specified parameter name can be a constant or an expression involving constants. In this context, DATE, TIME, and USER are considered constants.
  • If an error message is returned when a macro is executed, it can be caused by an SQL request in the macro.
  • The number of parameters used in the calling sequence must be equal to the number of parameters defined.
  • When, for example, two parameters are defined and used, if they are both null, the following requests are all valid unless defaults are specified in the macro definition:
         EXECUTE macro_1 '(, 1);
         EXECUTE macro_1 (,);
         EXECUTE macro_1 (NULL, NULL);

Access Logging and Errors

Any syntactic or semantic error identified and reported by the SQL parser results in an error being returned to you without logging the request.