Non-scrollable Cursor | Serial Cursor
Non-scrollable Cursor | Serial Cursor
The non-scrollable cursor processes the row(s) one by one from the beginning of the result table. NO SCROLL keyword is used to specify the cursor is non-scrollable.
If the SCROLL option is not coded, NO SCROLL is the default option. If the cursor is not scrollable, each FETCH operation positions the cursor at the next sequential row in the result set.
Positioned UPDATE and positioned DELETE operations are allowed on Non-scrollable cursors. Non-Scrollable Cursors" also called as "Serial Cursors.
Syntax -
EXEC SQL DECLARE cursor-name/cursor-variable-name NO SCROLL CURSOR FOR select-statement FOR FETCH ONLY END-EXEC.
Example -
Input -
Scenario1 - Declare non-scrolling cursor for retrieving all employee names from employee_details table.
Code -
EXEC SQL DECLARE E1 NO SCROLL CURSOR FOR SELECT EMP_NAME FROM EMPLOYEE_DETAILS END-EXEC.
Scenario2 - Declare the cursor for retrieving all employee names from the employee_details table.
Code -
EXEC SQL DECLARE E2 CURSOR FOR SELECT EMP_NAME FROM EMPLOYEE_DETAILS END-EXEC.