EXECUTE Examples | SQL Statements | Teradata Vantage - EXECUTE Examples - 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™

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', 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 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);