d) This example fetches the value of the last row (LAST specified) regardless of the current row. The cursor is
positioned to [8] in the following Figure: Example of positioning a cursor in different directions.
Example: FETCH LAST FROM CSR1 INTO :H1, :H2
e) This example fetches the value of the nth row from the first or last row regardless of the current row (ABSOLUTE
specified).
- The value of the second row from the first row is fetched. The cursor is positioned to [2] in the following Figure:
Example of positioning a cursor in different directions.
Example: FETCH ABSOLUTE 2 FROM CSR1 INTO :H1, :H2
- The value of the second row from the last row is fetched. The cursor is positioned to [7] in the following Figure:
Example of positioning a cursor in different directions.
Example: FETCH ABSOLUTE -2 FROM CSR1 INTO :H1, :H2
f) This example fetches the value of the nth row from the current row (RELATIVE specified).
- The value of the second row down from the current row is fetched. The cursor is positioned to [6] in the following
Figure: Example of positioning a cursor in different directions.
Example: FETCH RELATIVE 2 FROM CSR1 INTO :H1, :H2
- The value of the third row up from the current row is fetched. The cursor is positioned to [3] in the following Figure:
Example of positioning a cursor in different directions.
Example: FETCH RELATIVE -3 FROM CSR1 INTO :H1, :H2
[Figure: Example of updating data using a cursor (column to be updated is in the cursor tab
le)]
4.5 Updating Data Using a Cursor
Use an UPDATE statement to update data in a row in which a cursor is positioned. An updatable cursor must be used
in an UPDATE statement. The following is an example of specifying an UPDATE statement:
Example 1:
In this example, STOCKQTY is updated to "150" for the row in which the cursor is positioned in Figure:
Example of using a FETCH statement to position a cursor.
53