EasyManuals Logo

IBM DB2 User Manual

IBM DB2
585 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #131 background imageLoading...
Page #131 background image
c. If the iterator is pointing to a row of the result table, execute an SQL
UPDATE... WHERE CURRENT OF :iterator-object statement in an executable
clause to update the columns in the current row. Execute an SQL DELETE...
WHERE CURRENT OF :iterator-object statement in an executable clause to
delete the current row.
For a named iterator, do this by performing the following actions in a loop:
a. Invoke the next method to move the iterator forward.
b. Test whether the iterator is pointing to a row of the result table by checking
whether next returns true.
c. Execute an SQL UPDATE... WHERE CURRENT OF iterator-object statement
in an executable clause to update the columns in the current row. Execute
an SQL DELETE... WHERE CURRENT OF iterator-object statement in an
executable clause to delete the current row.
6. Close the iterator.
Use the close method to do this.
The following code shows how to declare a positioned iterator and use it for
positioned UPDATEs. The numbers to the right of selected statements correspond
to the previously described steps.
First, in one file, declare positioned iterator UpdByPos, specifying that you want to
use the iterator to update column SALARY:
Then, in another file, use UpdByPos for a positioned UPDATE, as shown in the
following code fragment:
import java.math.*; // Import this class for BigDecimal data type
#sql public iterator UpdByPos implements sqlj.runtime.ForUpdate 1
with(updateColumns="SALARY") (String, BigDecimal);
Figure 32. Example of declaring a positioned iterator for a positioned UPDATE
Chapter 4. SQLJ application programming 115

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the IBM DB2 and is the answer not in the manual?

IBM DB2 Specifications

General IconGeneral
DeveloperIBM
Initial Release1983
LicenseProprietary
Written inC, C++
CategoryDatabase Management System (RDBMS)
Operating SystemLinux, Windows
Programming LanguagesC, C++
Data ModelsRelational
EditionsCommunity, Standard, Advanced
Key Featureshigh availability, scalability