Semantic Errors May Not Reported When a Macro Is Created - Teradata VantageCloud Lake

Lake - Working with SQL

Deployment
VantageCloud
Edition
Lake
Product
Teradata VantageCloud Lake
Release Number
Published
February 2025
ft:locale
en-US
ft:lastEdition
2025-11-21
dita:mapPath
jbe1714339405530.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
jbe1714339405530

The system checks the macro text for syntax errors, but not for semantic errors for EXEC and DDL statements. Therefore, a macro may be valid syntactically but not semantically. The macro is created and no warning is returned.

If there are semantic errors in the macro definition, then a message is returned to the requestor when you perform it.

For example, it is possible to create or replace a macro definition that contains an EXEC request for a macro that is not defined in the system. The following example creates the macro without returning an error even though the macro it performs, no_such_macro, is not defined in the database:

     CREATE MACRO test_macro AS (
       EXEC no_such_macro;);

The system creates the macro as requested. It is only when you try to run test_macro that you discover the semantic error:

     EXEC test_macro;

     EXEC test_macro;
     *** Failure 3824 Macro 'no_such_macro' does not exist.
                    Statement# 1, Info =0
       *** Total elapsed time was 1 second.

This failure to enforce semantic correctness is restricted to EXEC requests and DDL requests. If a macro definition contains any DML requests, then the objects those statements reference must exist or the system aborts the attempt to create the macro.

Because the following CREATE MACRO request refers to nonexistent table_1, the system stops it and returns an error to the requestor.

     CREATE MACRO test_macro_2 AS (
      SELECT *
      FROM table_1;);

     CREATE MACRO test_macro_2 AS (SELECT * FROM table_1;);
     *** Failure 3807 Object 't1' does not exist.
                    Statement# 1, Info =0
     *** Total elapsed time was 1 second.