Databases Reference
In-Depth Information
For simplicity, we work with a single table to manage the inventory for the
company. You need to create the SAMPLE database provided with DB2
Express-C for this program, because it will interact with the INVENTORY table. If
the database does not exist, refer to Chapter 1, “DB2 application development
overview” on page 1 for steps about how to create the database.
The application interacts with the user to perform the following operations:
Enter a new product:
- New products need to be entered into the database. For a new product, its
product ID/barcode, quantity on hand, and location information need to be
added to the INVENTORY table.
- An error will occur if the product already exists in the database.
Update quantity/Update location:
- Any changes in the quantity or location of a product need to be reflected in
the table.
- An error will occur if the product does not exist in the database.
Get information about a part:
-
The user can query the database for a product to get information about the
quantity at hand or its location.
-
An error will occur if the product does not exist in the database.
4.3.1 The INVENTORY table
The INVENTORY table in the SAMPLE database consists of three columns named
PID, QUANTITY, and LOCATION. They store the ID/barcode, quantity on hand,
and the location of a product. The PID column is the unique identifier for a
product and must be distinct within the table. By default, the INVENTORY table
in the SAMPLE database is populated with the records shown in Example 4-3.
Example 4-3 Sample data from the INVENTORY table
PID QUANTITY LOCATION
---------- ----------- -----------
100-100-01 5 -
100-101-01 25 Store
100-103-01 55 Store
100-201-01 99 Warehouse
Search WWH ::




Custom Search