Generating SQL from a Macro - Teradata

Macros can also be used to easily perform administrative functions that would otherwise require manual intervention. As a matter of fact, NCR distributes several macros with the installation of Teradata to monitor things like space utilization.

I teach several classes for the same Teradata customers. When this occurs, there are usually tables, views and macros left over from the previous class. There is not always a lot of time available to drop these objects either before or after a class. So, I needed a fast way to accomplish that operation. A macro was the perfect solution.

The next macro builds DROP TABLE statements using BTEQ:

To execute the macro and SQL created from BTEQ:

EXEC Dropper ('mikel'); .RUN FILE=dropfile.txt

The Teradata database has not historically had stored procedures. Instead, it offered the functionality of macros. Stored Procedures are new with V2R4 and provide conditional processing logic in addition to the SQL. As a result, conditional and looping logic are now available for use in tools other than BTEQ, such as Queryman.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd Protection Status

Teradata Topics