Table of ContentsPreviousNext

Database Migration


Cursor Declaration

This subsection describes cursor declaration statements in various databases and their conversion by SQLWays. You must declare a cursor before referencing it in other statements. When declaring a cursor you associate it with a specific query

TABLE 32. Cursor Declaration Statements in Various Databases
Database
Statement
Description
Microsoft SQL Server

DECLARE cursor_name CURSOR
[ LOCAL | GLOBAL ]
[ FORWARD_ONLY | SCROLL ]
FOR select_statement
[ FOR UPDATE [OF column1 [{ , columnN...} ]]]

Declares a cursor and defines its attributes such as scrolling behavior and the query used to build the result set for the cursor.
FORWARD_ONLY specifies that the cursor can only be scrolled from the first to the last row. FETCH NEXT is the only supported fetch option.
SCROLL specifies access to fetch options (FIRST, LAST, PRIOR, NEXT, RELATIVE, ABSOLUTE) are available.
 
select_statement specifies a SELECT statement that defines the result set of the cursor.
Oracle

CURSOR cursor_name
[(
cur_param1 [IN] data_type [ {:= | DEFAULT} exp]
[, cur_paramN [IN] data_type [ {:= | DEFAULT} exp]...
)]
IS select_statement;

Declares a cursor and associates it with a specific query.
cur_paramN is a formal cursor parameter that can appear in a query wherever a constant can appear. The formal parameters of a cursor must be IN parameters. The query can also reference other PL/SQL variables within its scope.
Select_statement is a query that returns a result set. If the cursor declaration declares parameters, each parameter must be used in the query.
MySQL

DECLARE cursor_name CURSOR FOR select_statement

Declares a cursor and associates it with a specific query.
select_statement specifies a SELECT statement that defines the result set of the cursor.


Ispirer Systems
http://www.ispirer.com
ispirer@ispirer.com
Table of ContentsPreviousNext