IBM Books

Administration Guide


Using a Single Database in a Transaction

The simplest form of database usage is to read and write to only one database within a single transaction (unit of work). This type of database access is called remote unit of work.

Figure 36. Using a Single Database in a Transaction


sqld0rw1


Figure 36 shows an example of a database client running a funds transfer application that accesses a database containing checking and savings account tables, as well as a banking fee schedule. The application performing the transfer includes the following steps:

  1. Accept the amount to transfer from the user interface
  2. Subtract the amount from the savings account and determine the new balance
  3. Read the fee schedule to determine the transaction fee for a savings account with the given balance
  4. Subtract the transaction fee from the savings account
  5. Add the amount of the transfer to the checking account
  6. Commit the transaction (unit of work).

To set up this funds transfer application, you must:

  1. Create the tables for the savings account, checking account and banking fee schedule in the same database (Chapter 3. "Implementing Your Design")

  2. (If physically remote...) Set up the database server to use the appropriate communications protocol, as described in the Quick Beginnings manuals

  3. (If physically remote...) Catalog the node and database to identify the database on the above database server, as described in the Quick Beginnings manuals

  4. Pre-compile your application program to specify a type 1 connection, that is, specify CONNECT(1) on the PREP command, as described in the Embedded SQL Programming Guide manual.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]

[ DB2 List of Books | Search the DB2 Books ]