POSITION | Teradata Vantage - POSITION - Teradata Vantage - Analytics Database

SQL Stored Procedures and Embedded SQL

Deployment
VantageCloud
VantageCore
Edition
VMware
Enterprise
IntelliFlex
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
ft:locale
en-US
ft:lastEdition
2023-10-30
dita:mapPath
frc1628111662093.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
rjx1472253414573
lifecycle
latest
Product Category
Teradata Vantage™

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 either forward or backward from the current statement and can be repositioned to a given statement as many times 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 re-executed, but the cursor position in the spool file is adjusted accordingly.

You cannot execute POSITION as a dynamic SQL statement.

Related Information