IBM DB2 Manual page 147

Table of Contents

Advertisement

same application process are immediately visible. Rows that are inserted or deleted
with INSERT and DELETE statements that are executed by other application
processes are visible after the changes are committed.
Important: DB2 Database for Linux, UNIX, and Windows servers do not support
dynamic scrollable cursors. You can use dynamic scrollable iterators in your SQLJ
applications only if those applications access data on DB2 for z/OS servers, at
Version 9 or later.
Important:
To create and use a scrollable iterator, you need to follow these steps:
1. Specify an iterator declaration clause that includes the following clauses:
v implements sqlj.runtime.Scrollable
This indicates that the iterator is scrollable.
v with (sensitivity=INSENSITIVE|SENSITIVE|ASENSITIVE) or with
(sensitivity=SENSITIVE, dynamic=true|false)
sensitivity=INSENSITIVE|SENSITIVE|ASENSITIVE indicates whether update or
delete operations on the underlying table can be visible to the iterator. The
default sensitivity is INSENSITIVE.
dynamic=true|false indicates whether the size of the result table or the order
of the rows in the result table can change after the iterator is opened. The
default value of dynamic is false.
The iterator can be a named or positioned iterator.
Example: The following iterator declaration clause declares a positioned,
sensitive, dynamic, scrollable iterator:
#sql public iterator ByPos
implements sqlj.runtime.Scrollable
with (sensitivity=SENSITIVE, dynamic=true) (String);
Example: The following iterator declaration clause declares a named,
insensitive, scrollable iterator:
#sql public iterator ByName
implements sqlj.runtime.Scrollable
with (sensitivity=INSENSITIVE) (String EmpNo);
Restriction: You cannot use a scrollable iterator to select columns with the
following data types from a table on a DB2 Database for Linux, UNIX, and
Windows server:
v LONG VARCHAR
v LONG VARGRAPHIC
v BLOB
v CLOB
v A distinct type that is based on any of the previous data types in this list
v A structured type
2. Create an iterator object, which is an instance of your iterator class.
3. If you want to give the SQLJ runtime environment a hint about the initial fetch
direction, use the setFetchDirection(int direction) method. direction can be
FETCH_FORWARD or FETCH_REVERSE. If you do not invoke setFetchDirection, the
fetch direction is FETCH_FORWARD.
4. For each row that you want to access:
For a named iterator, perform the following steps:
Chapter 4. SQLJ application programming
131

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents