DECLARE CURSOR (Macro Form) | Teradata Vantage - DECLARE CURSOR (Macro Form) - Advanced SQL Engine - Teradata Database

SQL Stored Procedures and Embedded SQL

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Published
July 2021
Language
English (United States)
Last Update
2021-07-28
dita:mapPath
vqj1592443206677.ditamap
dita:ditavalPath
vqj1592443206677.ditaval
dita:id
B035-1148
lifecycle
previous
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