DECLARE CURSOR (Macro Form) | Teradata Vantage - DECLARE CURSOR (Macro Form) - Teradata Vantage - Analytics Database

SQL Stored Procedures and Embedded SQL

Deployment
VantageCloud
VantageCore
Edition
VMware
Enterprise
IntelliFlex
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Publication Date
June 2022
Content Type
SQL Reference
Publication ID
B035-1148-172K
ft:locale
en-US
ft:lastEdition
2023-10-30
dita:mapPath
frc1628111662093.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
ft:sourceId
dita
dita:id
rjx1472253414573
lifecycle
latest
Product Category
Teradata Vantageā„¢

The macro form of DECLARE CURSOR associates a cursor with a Teradata SQL macro.

ANSI Compliance

A Teradata extension to the ANSI/ISO SQL:2011 standard because macros are not defined in ANSI/ISO SQL.

Required Privileges

None.

Syntax

DECLARE cursor_name CURSOR FOR EXEC
  [ database_name. ] macro_name [ ( parameter_list ) ]

Syntax Elements

cursor_name
Any valid SQL identifier.
database_name
The database to be used with the statement.
macro_name
The name of the Teradata SQL macro to be executed.
parameter_list
The Teradata SQL macro parameters.

Usage Notes

  • Usage Notes (All Forms)
  • The system executes the macro when the cursor is opened. Then the application program accesses the results as the results of a request cursor.
  • None of the statements in the specified macro can be preprocessor or stored procedure declaratives.
  • The macro cannot include any of the following SQL statements:
    • CHECKPOINT
    • CLOSE
    • COMMIT
    • CONNECT
    • DATABASE
    • DESCRIBE
    • ECHO
    • EXECUTE
    • EXECUTE IMMEDIATE
    • FETCH
    • LOGON
    • OPEN
    • POSITION
    • PREPARE
    • REWIND
    • SET BUFFERSIZE
    • SET CHARSET
    • SET SESSION

Example: Structuring the Macro DECLARE CURSOR Statement

Structure the macro DECLARE CURSOR statement as follows:

DECLARE Ex CURSOR FOR EXEC NewEmp