EXECUTE Examples | SQL Statements | Teradata Vantage - EXECUTE Examples - Advanced SQL Engine - Teradata Database

SQL Data Manipulation Language

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Published
July 2021
Language
English (United States)
Last Update
2021-07-27
dita:mapPath
vjt1596846980081.ditamap
dita:ditavalPath
vjt1596846980081.ditaval
dita:id
B035-1146
lifecycle
previous
Product Category
Teradata Vantage™

Example: Named Parameter List

This request uses a named parameter list to execute macro new_emp1. See CREATE MACRO in Teradata Vantage™ - SQL Data Definition Language Syntax and Examples, B035-1144. Named parameters can be listed in any order.

     EXECUTE new_emp1(number=10015, dept=500, name='Omura H', sex='M',
             position='Programmer');

The row for new employee Omura is inserted in the employee table.

Example: Positional Parameter List

This example uses a positional parameter list to execute macro new_emp2. See CREATE MACRO in Teradata Vantage™ - SQL Data Definition Language Syntax and Examples, B035-1144. Note that a value is not specified for the dept parameter, which has a macro-defined default value. A comma is entered in the dept position to maintain the integrity of the positional sequence.

     EXECUTE new_emp2 (10021, 'Smith T', , 'Manager', 'F', 
             'May 8, 1959', 16);

Example: Automatically Inserted Value

When the following request is processed, the default value for the dept parameter (900) is inserted automatically. The row for new employee Smith is added to the employee table, and then the department table is updated by incrementing the value for Department 900 in the emp_count column. The request uses a named parameter list to execute a macro named new_hire. Note that the value of the DOH (Date of Hire) column is an expression involving the DATE constant.

     EXECUTE new_hire (fl_name='Toby Smith', title='Programmer',
             doh=DATE -1);

Example: Invoking an SQL UDF as an Argument to Macro Execution

The following example invokes the SQL UDF value_expression as an argument to the macro m1.

     EXECUTE m1 (test.value_expression(1,2), 2, 3);