15.00 - 15.10 - Cursors - Teradata Database

Teradata Database Introduction to Teradata

Product
Teradata Database
Release Number
15.00
15.10
Content Type
User Guide
Publication ID
B035-1091-151K
Language
English (United States)
Last Update
2018-09-25

Traditional application development languages cannot deal with result tables without some kind of intermediary mechanism because SQL is a set-oriented language. The intermediary mechanism is the cursor.

A cursor is a pointer that the application program uses to move through a result table.

You declare a cursor for a SELECT request, and then open the named cursor. The act of opening the cursor executes the SQL request.

You use the FETCH... INTO... statement to individually fetch and write the rows into host variables. The application can then use the host variables to do 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 to fetch one result row at a time and then to execute SQL and SQL control statements as required for each row. Local variables or parameters from the stored procedure can be used for computations.
  • Result set cursors to return the result of a SELECT statement executed in the stored procedure to the caller of the stored procedure or the client application.
  • For more information on the topics presented in this chapter, see the following Teradata Database books.

     

    If you want to learn more about…

    See…

    SQL

    SQL Fundamentals

    Types of SQL Statements

  • SQL Data Control Language
  • SQL Data Definition Language
  • SQL Data Manipulation Language
  • The SELECT Statement

  • SQL Data Manipulation Language
  • SQL Functions, Operators, Expressions, and Predicates
  • SQL Fundamentals
  • SQL Data Types

    SQL Data Types and Literals

    Teradata Database Recursive Query

    SQL Fundamentals

    SQL Functions

    SQL Functions, Operators, Expressions, and Predicates

    Cursors

  • SQL Data Definition Language
  • SQL Stored Procedures and Embedded SQL
  • Session Modes

  • SQL Fundamentals
  • SQL Request and Transaction Processing