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

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
Language
English (United States)
Last Update
2024-04-03
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

Example: Named Parameter List

This request uses a named parameter list to run macro new_emp1. See CREATE MACRO. Named parameters can be listed in any order.

run new_emp1(number=10015, dept=500, name='Omura H', gender='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. 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. 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);