DECLARE CURSOR | Teradata Vantage - DECLARE CURSOR - Advanced SQL Engine - Teradata Database

SQL Stored Procedures and Embedded SQL

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
17.00
Published
June 2020
Language
English (United States)
Last Update
2021-01-23
dita:mapPath
xqq1557098602407.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1148
lifecycle
previous
Product Category
Teradata Vantage™

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

For more information about: