sqlj.runtime
Interface PositionedIterator
- All Superinterfaces:
- ResultSetIterator
- public interface PositionedIterator
- extends ResultSetIterator
An interface implemented by all iterators that employ a by-position
binding strategy. All such iterators depend on the position of the columns of
the data to which they are bound, as opposed to the names of the columns to
which they are bound.
In addition to implementing this interface, position-bound iterator
implementations will provide:
- A public constructor which takes an RTResultSet as a parameter.
If the construction of a positioned iterator results in an exception being
thrown, it is assumed that the iterator automatically closes the
underlying result set. This only applies to exceptions thrown during
construction. This constructor is for internal use of the SQLJ runtime only. Please
use the SQLJ CAST statement instead.
- An accessor method for each column in the expected result. The name
of the accessor method for the nth column will be
getColN(). These accessor methods are for internal use by the SQLJ runtime only.
Please use the SQLJ FETCH ... INTO statement to access the colums of a
positional iterator.
A common usage of a PositionedIterator is as follows:
#sql iterator StringIter(String);
[...]
IntIter posIter;
String val;
#sql [ctx] posIter = { SELECT the_value FROM tab WHERE the_key = 1 };
try {
while (true) {
#sql { FETCH :posIter INTO :val };
if (c.endFetch()) break;
[...]
}
} finally {
posIter.close();
}
- See Also:
NamedIterator,
ResultSetIterator
|
Method Summary |
boolean |
endFetch()
Returns true iff the iterator is not positioned on a row. |
endFetch
public boolean endFetch()
throws java.sql.SQLException
- Returns
true iff the iterator is not positioned on a row. This
method is used to determine the success of a FETCH ... INTO statement; it
returns true if the last attempt to fetch a row failed,
false if the last attempt was successful. Rows are attempted to
be fetched when the next() method is called (which is called
implicitely during the execution of a FETCH ... INTO statement).
Note: If next() has not yet been called, this method
returns true;
A common usage of this method is as follows:
while (true) {
#sql { FETCH :c INTO ... };
if (c.endFetch()) break;
[...]
}
- Throws:
java.sql.SQLException - if a databse access error occurs- See Also:
ResultSetIterator.next()