Updating a single database in a multi-database transaction

If your data is distributed across multiple databases, you may wish to update one database while reading from one or more other databases. This type of access can be performed within a single unit of work (transaction).

Before you begin

Note: If databases are located on a host or System i database server, you require Db2 Connect for connectivity to these servers.

About this task

Figure 1. Using multiple databases in a single transaction
Figure 1 shows a database client running a funds transfer application that accesses two database servers: one containing the checking and savings accounts, and another containing the banking or transaction fee payment table.

Procedure

To set up a funds transfer application for this environment, you must:

  1. Create the necessary tables in the appropriate databases
  2. If physically remote, set up the database servers to use the appropriate communications protocols
  3. If physically remote, catalog the nodes and the databases to identify the databases on the database servers
  4. Precompile your application program to specify a type 2 connection (that is, specify CONNECT 2 on the PRECOMPILE command), and one-phase commit (that is, specify SYNCPOINT ONEPHASE on the PRECOMPILE command).