Reference Guide > TDV SQL Script > SQL Language Concepts > Cursor Variables
 
Cursor Variables
Cursor variables in SQL Script are expressions or other elements that resolve to cursors. You can define a cursor variable by providing a unique name and optionally specifying its data type, as described in DECLARE CURSOR of Type Variable.
Syntax
DECLARE <varName> CURSOR
[<dataType>]
Remarks
The optional <dataType> can be a named ROW data type, or the syntax for a ROW data type.
The syntax for a ROW data type is: <colName> <dataType> [,…].
There are no attributes on a ROW variable.
You access a row using rowVar.columnName to get a column.
When declared, cursor variables are initialized to NULL. They cannot be initialized to any other value at declaration.
A cursor variable with a type can be assigned from any cursor with the same ROW type, or to any cursor variable with the same ROW type.
A cursor variable without a type can be assigned from any cursor, or to any cursor. Assigning to a typed cursor forces a run-time schema match comparison and raises an exception on a mismatch.
Assigning a cursor creates a reference to the original cursor’s state. This means that opening, closing, or fetching from the original cursor or the variable has the same effect, and alters what the other would see.
For further information, see Attributes of Cursors, OPEN, FETCH, and CLOSE.