Cursors - Teradata Vantage - Analytics Database

Database Introduction

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
2025-11-21
dita:mapPath
gtm1628096154303.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
dsm1472253642401
lifecycle
latest
Product Category
Teradata Vantageā„¢

Because SQL is set-oriented, traditional application development languages need an intermediary mechanism for moving through a result table. The intermediary mechanism is a pointer called a cursor.

Declare a named cursor for a SELECT request and open the cursor. Opening the cursor executes the SQL request.

Use the FETCH INTO statement to individually fetch and write the rows into host variables. The application can then use the host variables in computations.

Teradata Preprocessor2 uses cursors to mark or tag the first row accessed by an SQL query. Preprocessor2 then increments the cursor as needed.

SQL stored procedures use cursors for the following purposes:
  • To fetch one result row at a time and then execute the SQL statements as required for each row.

    Computations can use local variables or parameters from the stored procedure.

  • To return the result of a SELECT statement executed in the stored procedure to the caller of the stored procedure or the client application.