How will you implement a logic which will enable the cursor to read data in both forward and backward direction?

DB2DatabaseBig Data Analytics

A cursor can move only in forward direction, which means that it can extract the next row after every fetch. It is not possible to extract the previous row using a cursor.For example, if our resultant cursor contains following rows−

ORDER_IDORDER_DATE
A223672020-07-28
A667562020-07-28
A778902020-07-29
A968322020-07-29

If our cursor is currently pointing to 3rd row i.e. order id A77890 then the next fetch will point the cursor to the next row i.e. order id A96832. It is not possible to point the cursor to the previous order id i.e. A66756.

In order to achieve this, we use the concept of SCROLLABLE CURSOR. The SCROLLABLE CURSOR can move both in forward and backward direction, it can also move in the relative or absolute position from the current position. The SCROLLABLE CURSOR is very useful in implementing page up and page down logic in CICS screen.

raja
Published on 15-Sep-2020 14:36:09
Advertisements