15.00 - 15.10 - SQL Used to Modify a Macro - Teradata Database

Teradata Database Introduction to Teradata

Product
Teradata Database
Release Number
15.00
15.10
Content Type
User Guide
Publication ID
B035-1091-151K
Language
English (United States)
Last Update
2018-09-25

The following example shows how to modify a macro. Suppose you want to change the NewEmp macro so that the default department number is 300 instead of 100. The REPLACE MACRO statement looks like this:

    REPLACE MACRO NewEmp (name VARCHAR(12),
                          number INTEGER NOT NULL,
                          dept INTEGER DEFAULT 300)
    AS (INSERT INTO Employee (Name,
                              EmpNo,
                              DeptNo)
        VALUES (name,
                number,
                dept)
        ;
        UPDATE Department
        SET EmpCount=EmpCount+1
        WHERE DeptNo=dept
        ;
       )
    ;