NexusDB Manual V3 > SQL Reference > SQL Statements > Data Statements
Syntax
<fetch statement> ::=
Usage
The named cursor is positioned on the specified row in the result set defined by the cursor declaration. This row becomes the current row for the cursor.
Notes
NEXT - Position the cursor on the row next to the current row PRIOR - Position the cursor on the row prior to the current row FIRST - Position the cursor on the first row in the result set LAST - Position the cursor on the last row in the result set ABSOLUTE - Position the cursor on the row with a specified absolute row number in the result set. Row zero does not exist and will return NOT FOUND. Negative numbers count from the end of the result set (i.e. -1 = LAST) RELATIVE - Position the cursor on the row specified with a row number relative to the current row in the result set. Zero is the current row, positive numbers count toward the end of the result set and negative numbers toward the beginning.
1) The following example shows a fetch loop:
DECLARE acursor CURSOR FOR SELECT f1, f2 from table1; OPEN acursor; FETCH NEXT FROM acursor INTO myvar1, myvar2;
WHILE @@FETCH_STATUS = 0 DO INSERT INTO table2 values (myvar1, myvar2); FETCH NEXT FROM acursor INTO myvar1, myvar2; END WHILE; CLOSE acursor;
Conformance
|
© Nexus Database Systems Pty Ltd.