a. Position the cursor using one of the methods listed in the following table.
Table 20. sqlj.runtime.Scrollable methods for positioning a scrollable cursor
Method Positions the cursor
first
1
On the first row of the result table
last
1
On the last row of the result table
previous
1,2
On the previous row of the result table
next On the next row of the result table
absolute(int n)
1,3
If n>0, on row n of the result table. If n<0, and m is
the number of rows in the result table, on row m+n+1
of the result table.
relative(int n)
1,4
If n>0, on the row that is n rows after the current row.
If n<0, on the row that is n rows before the current
row. If n=0, on the current row.
afterLast
1
After the last row in the result table
beforeFirst
1
Before the first row in the result table
Notes:
1. This method does not apply to connections to IBM Informix Dynamic Server.
2. If the cursor is after the last row of the result table, this method positions the cursor on
the last row.
3. If the absolute value of n is greater than the number of rows in the result table, this
method positions the cursor after the last row if n is positive, or before the first row if n
is negative.
4. Suppose that m is the number of rows in the result table and x is the current row
number in the result table. If n>0 and x+n>m, the iterator is positioned after the last row.
If n<0 and x+n<1, the iterator is positioned before the first row.
b. If you need to know the current cursor position, use the getRow, isFirst,
isLast, isBeforeFirst,orisAfterLast method to obtain this information.
If you need to know the current fetch direction, invoke the
getFetchDirection method.
c. Use accessor methods to retrieve the current row of the result table.
d. If update or delete operations by the iterator or by other means are visible
in the result table, invoke the getWarnings method to check whether the
current row is a hole.
For a positioned iterator, perform the following steps:
a. Use a FETCH statement with a fetch orientation clause to position the
iterator and retrieve the current row of the result table. Table 21 lists the
clauses that you can use to position the cursor.
Table 21. FETCH clauses for positioning a scrollable cursor
Method Positions the cursor
FIRST
1
On the first row of the result table
LAST
1
On the last row of the result table
PRIOR
1,2
On the previous row of the result table
NEXT On the next row of the result table
ABSOLUTE(n)
1,3
If n>0, on row n of the result table. If n<0, and m is
the number of rows in the result table, on row m+n+1
of the result table.
132 Application Programming Guide and Reference for Java
â„¢