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