Purpose
Defines and assigns a name to a cursor.
Invocation
Nonexecutable declaration.
Stored procedures and embedded SQL.
Dynamic SQL Form of DECLARE CURSOR
The dynamic SQL form of DECLARE CURSOR associates a cursor with a dynamic SQL statement.
The dynamic SQL statement can be any of the following:
- A data returning statement
- A Teradata SQL macro
- An arbitrary request containing any combination of supported statements, including macros and data returning statements
- A Teradata Database stored procedure
Macro Form of DECLARE CURSOR
The macro form of DECLARE CURSOR associates a cursor with a Teradata SQL macro.
Request Form of DECLARE CURSOR
The request form of DECLARE CURSOR associates a cursor with an arbitrary Teradata SQL request, typically a multistatement request specified within an SQL string literal.
Selection Form of DECLARE CURSOR
The selection form of DECLARE CURSOR associates a cursor with a SELECT or other data returning statement.
Stored Procedures Form of DECLARE CURSOR
The stored procedures form of DECLARE CURSOR associates a cursor with a SELECT or other data returning statement within the body of a stored procedure FOR statement.
Rules (All Forms)
- Each cursor declaration must specify a different cursor name.
- A cursor name cannot exceed 18 characters.
- The cursor declaration for a particular cursor name must precede any references to that cursor name in other embedded SQL or stored procedure statements.
- In COBOL, you can specify the DECLARE CURSOR statement either in the DATA DIVISION or in the PROCEDURE DIVISION.
Related Topics
- The dynamic SQL form of DECLARE CURSOR, see DECLARE CURSOR (Dynamic SQL Form)
- The macro, request, selection, or stored procedures forms of DECLARE CURSOR, see DECLARE CURSOR (Macro Form)