This example application for distributed relational database use is written in RPG/400®, COBOL/400®, Java™ and ILE C/400® programming languages. This example shows how to use a distributed relational database for functional specification tasks.
The application for the distributed relational database in this example is parts stock management in an automobile dealer or distributor network.
This program checks the level of stock for each part in the local part stock table. If this is below the re-order point, the program then checks on the central tables to see whether there are any existing orders outstanding and what quantity has been shipped against each order.
If the net quantity (local stock, plus orders, minus shipments) is still below the re-order point, an order is placed for the part by inserting rows in the appropriate tables on the central server. A report is printed on the local server.
This program uses the concept of local and remote logical units of work (LUW). Because this program uses remote unit of work, it is necessary to close the current LUW on one server (COMMIT) before beginning a new unit of work on another server.
When an LUW is committed and the application connects to another database, all cursors are closed. This application requires the cursor reading the part stock file to be re-opened at the next part number. To achieve this, the cursor is defined to begin where the part number is greater than the current value of part number, and to be ordered by part number.