Examples: Application programming
This example application for distributed relational database use is written in RPG/400®, COBOL/400®, Java™, and ILE C programming languages. This example shows how to use a distributed relational database for functional specification tasks.
Example: Business requirement for distributed relational database
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 system. A report is printed on the local system.
Technical notes
- Commitment control
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 system (COMMIT) before beginning a new unit of work on another system.
- Cursor repositioning
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.
This technique will not work if there are duplicate rows for the same part number.
- Example: Program definitions
Here are the example program definitions for the parts stock management in an automobile dealer or distributor network.
- Example: RPG program
This example program is written in the RPG programming language.
- Example: COBOL program
This example program is written in the COBOL programming language.
- Example: C program using embedded SQL
This example program is written in the C programming language.
- Example: Java program
This example program is written in the Java programming language.
- Example: Program output
Here is the program output for the parts stock management example.
Parent topic:
Distributed database programming