Macros and Tactical Queries - Teradata Database

Teradata Database Design

Teradata Database
Release Number
English (United States)
Last Update
Product Category

Macros and Tactical Queries

You automatically get a multistatement request without coding it if you write multiple SQL statements within a macro because macros are always performed as a single request. The macro code can also specify parameters that are replaced by data each time the macro is performed. The most common way of substituting for the parameters is to specify a USING request modifier (see “USING Request Modifier” in SQL Data Manipulation Language).

Macros are usually more efficient for repetitive queries than single DML statements. Unlike procedures, macros are not designed to return parameters to the requestor: they return only the answer set for the SQL statements they contain.

Macros have the following advantages:

  • Network and channel traffic are reduced.
  • Execution plans can be cached, reducing parsing engine overhead.
  • They ensure the efficient performance of their component SQL statements.
  • Reusable database components save client resources.
  • They can be used to force data integrity and locking modifiers.
  • They can be used to enforce security.