EXECUTE Statement | SQL Statements | VantageCloud Lake - EXECUTE (Macro Form) - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
ft:locale
en-US
ft:lastEdition
2024-12-11
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

Performs a macro.

For information about the embedded SQL EXEC statement, which is used to run macros from embedded SQL applications, see EXEC SQL Statement Prefix.

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.

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 running user.

Therefore, object references in data definition statements must 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.
  • An SQL request in the macro can cause an error message is returned when a macro runs.
  • The number of parameters used in the calling sequence must be equal to the number of parameters defined.
  • When all parameters defined and used in the macro are null, requests like the following are 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 returns an error to you without logging the request.