IBM DB2 Manual page 137

Table of Contents

Advertisement

Other integer
This value is the number of rows that were updated by the statement. This
value is returned if the statement was executed rather than added to a
batch.
5. Execute the batch explicitly or implicitly.
v Invoke the ExecutionContext.executeBatch method to execute the batch
explicitly.
executeBatch returns an integer array that contains the number of rows that
were updated by each statement in the batch. The order of the elements in
the array corresponds to the order in which you added statements to the
batch.
v Alternatively, a batch executes implicitly under the following circumstances:
– You include a batchable statement in your program that is not compatible
with statements that are already in the batch. In this case, SQLJ executes
the statements that are already in the batch and creates a new batch that
includes the incompatible statement. SQLJ also executes the statement that
is not compatible with the statements in the batch.
– You include a statement in your program that is not batchable. In this
case, SQLJ executes the statements that are already in the batch. SQLJ also
executes the statement that is not batchable.
– After you invoke the ExecutionContext.setBatchLimit(n) method, you
add a statement to the batch that brings the number of statements in the
batch to n or greater. n can have one of the following values:
ExecutionContext.UNLIMITED_BATCH
This constant indicates that implicit execution occurs only when SQLJ
encounters a statement that is batchable but incompatible, or not
batchable. Setting this value is the same as not invoking
setBatchLimit.
ExecutionContext.AUTO_BATCH
This constant indicates that implicit execution occurs when the
number of statements in the batch reaches a number that is set by
SQLJ.
Positive integer
When this number of statements have been added to the batch, SQLJ
executes the batch implicitly. However, the batch might be executed
before this many statements have been added if SQLJ encounters a
statement that is batchable but incompatible, or not batchable.
To determine the number of rows that were updated by a batch that was
executed implicitly, invoke the ExecutionContext.getBatchUpdateCounts
method. getBatchUpdateCounts returns an integer array that contains the
number of rows that were updated by each statement in the batch. The order
of the elements in the array corresponds to the order in which you added
statements to the batch. Each array element can be one of the following
values:
-2 This value indicates that the SQL statement executed successfully, but the
number of rows that were updated could not be determined.
-3 This value indicates that the SQL statement failed.
Other integer
This value is the number of rows that were updated by the statement.
6. Optionally, when all statements have been added to the batch, disable batching.
Chapter 4. SQLJ application programming
121

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents