What is the usage of scrollable cursor for current positioning?



We can use SCROLLABLE CURSOR to directly point the cursor to the mentioned relative position. The relative position is the position of the row in the result table from the current row. For example, consider the table below.

ORDER_ID ORDER_DATE
A22367 2020-07-28
A66756 2020-07-28
A77890 2020-07-29
A96832 2020-07-29

If the cursor is currently pointing to the 2nd absolute row i.e, ORDER_ID A66756 then the relative +2 position will be ORDER_ID A96832 and relative -1 position will be ORDER_ID A22367.

The syntax to use relative position in FETCH statement is−

EXEC SQL
   FETCH RELATIVE +2 ORDER_CURR
   INTO :ORDER-ID, :ORDER-DATE
END-SQL
Updated on: 2020-09-15T11:14:12+05:30

210 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements