Types of Cursors:
1. Static Cursor
2. Dynamic Cursor
3. Keyset Cursor
4. Forward_Only Cursor
Syntax to declare the Cursor:
DECLARE CURSORNAME CURSOR CURSORTYPE FOR SELECT * FROM TABLENAME
Syntax to open the Cursor:
Open cursorname
Syntax to fetch the records from cursor:
Fetch {first/next/prior/last/absolute/relative n} from cursorname
Syntax to close the cursor:
Close cursorname
Syntax to deallocate the cursor:
Deallocate cursorname
FIRST: Fetches first record from the cursor
NEXT: Fetches next record from the current position of the cursor
PRIOR: Fetches previous record from the current position of the cursor
LAST: Fetches last record from the cursor
ABSOLUTE N: Fetches nth record from the top of the cursor if n positive fetches the nth record from bottom of the cursor if n is negative. Where n is an integer.
RELATIVE N: Fetches nth next record from current position of the cursor if n is positive fetches nth previous record from the current position of the cursor if n is negative where n is an integer.

No comments:
Post a Comment