POSITION Statement | VantageCloud Lake - POSITION - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
Language
English (United States)
Last Update
2024-04-03
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

Positions a cursor to the beginning of the next statement or to the results of a specified statement.

ANSI Compliance

POSITION is ANSI/ISO SQL:2011-compliant.

Required Privileges

None.

Invocation

Executable.

Embedded SQL only.

Syntax

POSITION cursor_name
  [ TO
    { NEXT |
      [STATEMENT] { statement_number | [:] numeric_variable }
    }
  ]

Syntax Elements

cursor_name
The name of an open cursor other than an Insertion cursor.
statement_number
An integer numeric for the statement number to which positioning is desired.
numeric_variable
A host variable conforming to type INTEGER that represents the statement number to which positioning is desired. Use of a colon character is optional.

Usage Notes

The cursor is repositioned before the first result row (if any) of the statement specified and SQLSTATE, SQLCODE and other SQLCA values are set.

With POSITION TO NEXT, the cursor is positioned to the next statement.

With POSITION TO STATEMENT, the cursor is positioned to the specified statement.

If the specified statement number does not exist (for example, TO STATEMENT 3 is coded, but the cursor controls only two statements), the following runtime exception occurs, leaving the position of the cursor undefined:
  • SQLCODE is set to -501
  • SQLSTATE is set to ‘24501’

The cursor can be positioned forward or backward from the current statement and can be repositioned to a given statement as often as the application requires.

For COBOL programs with multiple compile units, the cursor can only be positioned backward if a REWIND or POSITION TO STATEMENT occurs in the same compile unit as the declaration and the opening of the cursor.

POSITION is valid with any cursor except an insertion cursor.

The statement set found by the cursor is not rerun, but the cursor position in the spool file is adjusted accordingly.

You cannot run POSITION as a dynamic SQL statement.

Related Information