HP 3000 Manuals

ORDERS Database Model Program [ TurboIMAGE/XL Database Management System Reference Manual ] MPE/iX 5.5 Documentation


TurboIMAGE/XL Database Management System Reference Manual

ORDERS Database Model Program 

Main Body of Program 

     BEGIN MAIN LINE

     *    OBJECTIVE:  The main line contains the logic of this application.
     *                It displays all functions, accepts a selection,
     *                then calls the appropriate routines.  The execution
     *                of this program stops after the database is closed.
     *
     *    ACCESS:     Not applicable.
     *
     *    CALLED BY:  Not applicable.
     *
     *    CALLS:      Open_The_Database
     *                Get_Sales_For_Date
     *                Get_A_Customer_Record
     *                Get_A_Product_Record
     *                List_All_Customers
     *                Add_A_Product
     *                Update_A_Customer
     *                Delete_A_Product
     *                Rewind_Customer_Set
     *                Get_Data_Item_Info
     *                Get_Error_And_Explain
     *                Close_The_Database

          START LOOP

               DISPLAY the list of functions

The following illustration depicts one way of displaying the list of
functions for this program.

[]
OBTAIN option <---- user input If option = 1 Then CALL Open_The_Database and RETURN If option = 2 Then CALL Get_Sales_For_Date and RETURN If option = 3 Then CALL Get_A_Customer_Record and RETURN If option = 4 Then CALL Get_A_Product_Record and RETURN If option = 5 Then CALL List_All_Customers and RETURN If option = 6 Then CALL Add_A_Product and RETURN If option = 7 Then CALL Update_A_Customer and RETURN If option = 8 Then CALL Delete_A_Product and RETURN If option = 9 Then CALL Rewind_Customer_Set and RETURN If option = 10 Then CALL Get_Data_Item_Info and RETURN If option = 11 Then CALL Get_Error_And_Explain and RETURN If option = 12 Then CALL Close_The_Database and RETURN EXIT LOOP if option = 12 END LOOP END MAIN LINE Opening the Database (USER SELECTS 1 TO OPEN THE DATABASE) ROUTINE: Open_The_Database * OBJECTIVE: This routine opens the ORDERS database in mode 1 * for this application. * * ACCESS: Mode 1 - Shared Modify Access (SMA) with locking required * * CALLED BY: Main Line * * CALLS: DBOPEN in mode 1 (SMA) BEGIN ROUTINE OBTAIN DBname <---- "__ORDERS;" OBTAIN Password <---- "DO-ALL;" CALL DBOPEN (DBname, Password, Mode1_SMA, Status) ERROR CHECKING END ROUTINE Retrieving All the Records on a Chain (with Item Level Locking) (USER SELECTS 2 TO RETRIEVE SALES DATA) ROUTINE: Get_Sales_For_Date * OBJECTIVE: This routine demonstrates chained access, forward chained * read, and data item locking. * * The routine retrieves all sales records generated * on a particular purchase date. The value for date is * provided by the user and is used as the search item. * Due to concurrency issues, a data item lock is acquired * on all sales records identified by the date. * * ACCESS: Mode 1 - Shared Modify Access * * CALLED BY: Main Line * * CALLS: DBLOCK in mode 5 (unconditional) * DBFIND in mode 1 (chained access) * DBGET in mode 5 (forward chained read) * DBUNLOCK in mode 1 (unlock) BEGIN ROUTINE Sales_Buffer is made up of: Account Stock# Quantity Price Tax Total Purch-Date Deliv-Date Lock_Descriptor_Sales_Type is made up of: Length_Of_Descriptor Data_Set_Of_Descriptor Data_Item_Of_Descriptor Relative_Operator_For_Data_Item Value_For_Data_Item Lock_Descriptor_Sales_Array_Type is made up of: Number_Of_Elements Lock_Descriptor_Sales_Type The following illustration shows the layout for a lock descriptor array formats after the actual values have been assigned. Note that the date is stored in YYMMDD format.
[]
OBTAIN Number_Of_Elements <---- 1 OBTAIN Length_Of_Descriptor <---- 21 OBTAIN Data_Set_Of_Descriptor <---- "SALES;" OBTAIN Data_Item_Of_Descriptor <---- "PURCH-DATE;" OBTAIN Relative_Operator_For_Data_Item <---- "_=" OBTAIN Value_For_Data_Item <---- "881012" OBTAIN List <---- "@;" OBTAIN Search_Item_Name <---- "PURCH-DATE;" OBTAIN Search_Item_Value <---- "881012" CALL DBLOCK (DBname, Lock_Descriptor_Sales_Array_Type, Mode5_Unconditional, Status) ERROR CHECKING CALL DBFIND (DBname, Sales_Detail, Mode1_Chained_Read, Status, Search_Item_Name, Search_Item_Value) ERROR CHECKING START LOOP CALL DBGET (DBname, Sales_Detail, Mode5_Forward, Status, List, Sales_Buffer, Not_Used_Parm) ERROR CHECKING DISPLAY the Sales_Buffer ____________________________________________________________________ Account Stock# Quantity Price Tax Total Purch-Date Deliv-Date EXIT LOOP if end of chain END LOOP CALL DBUNLOCK (DBname, Lock_Desc_Array, Mode1_Unlock, Status) ERROR CHECKING END ROUTINE Retrieving a Data Entry Using a Record Number (USER SELECTS 3 TO RETRIEVE CUSTOMER DATA) ROUTINE: Get_A_Customer_Record * OBJECTIVE: This routine demonstrates directed access by retrieving * a customer record with a known record number. Note * that the record number is first obtained using a DBGET * call, which in this case is a calculated mode 7. * * ACCESS: Mode 1 - Shared Modify Access * * CALLED BY: Main Line * * CALLS: DBGET in mode 7 (calculated read) * DBGET in mode 4 (directed read) BEGIN ROUTINE Customer_Buffer is made up of: Account Last-Name First-Name Initial Street-Address City State Zip Credit-Rating OBTAIN List <---- "@;" OBTAIN Key_Item_Value <---- 315578 CALL DBGET (DBname, Customer_Master, Mode7_Calculated, Status, List, Customer_Buffer, Key_Item_Value) ERROR CHECKING OBTAIN Record_Num <---- Status [element 3] CALL DBGET (DBname, Customer_Master, Mode4_Directed, Status, List, Customer_Buffer, Record_Num) ERROR CHECKING DISPLAY the Customer_Buffer ____________________________________________________________________ Account Last-Name First-Name Initial Street-Address City. . . END ROUTINE Retrieving Master Data Using a Key Value (USER SELECTS 4 TO RETRIEVE PRODUCT DATA) ROUTINE:Get_A_Product_Record * OBJECTIVE: This routine demonstrates calculated access by * retrieving a product record from a master data * set based on a user-defined key item value. * * ACCESS: Mode 1 - Shared Modify Access * * CALLED BY: Main Line * * CALLS: DBGET in mode 7 (calculated read) BEGIN ROUTINE Product_Buffer is made up of: Stock# Description OBTAIN List <---- "@;" OBTAIN Key_Item_Value <---- "STK30040" CALL DBGET (DBname, Product_Master, Mode7_Calculated, Status, List, Product_Buffer, Key_Item_Value) ERROR CHECKING DISPLAY the Product_Buffer ____________________________________________________________________ Stock# Description END ROUTINE Retrieving Data Serially (with Set Level Locking) (USER SELECTS 5 TO RETRIEVE CUSTOMER DATA) ROUTINE: List_All_Customers * OBJECTIVE: This routine demonstrates serial access by listing * all customer records. For the sake of consistency, * the data set is locked for exclusive access, * then the data is read serially. * * ACCESS: Mode 1 - Shared Modify Access * * CALLED BY: Main Line * * CALLS: DBLOCK in mode 3 (unconditional) * DBGET in mode 2 (forward read) * DBUNLOCK in mode 1 (unlock) BEGIN ROUTINE Customer_Buffer is made up of: Account Last-Name First-Name Initial Street-Address City State Zip Credit-Rating CALL DBLOCK (DBname, Customer_Master, Mode3_Unconditional, Status) ERROR CHECKING OBTAIN List <---- "Account, Last-Name, First-Name, Initial;" START LOOP CALL DBGET (DBname, Customer_Master, Mode2_Forward, Status, List, Customer_Buffer, Not_Used_Parm) ERROR CHECKING DISPLAY List ____________________________________________________________________ Account Last-Name First-Name Initial EXIT LOOP if first word of Status buffer <> 0 END LOOP CALL DBUNLOCK (DBname, Customer_Master, Mode1_Unlock, Status) ERROR CHECKING END ROUTINE Adding an Entry (USER SELECTS 6 TO DO A PUT) ROUTINE: Add_A_Product * OBJECTIVE: This routine adds one entry to the Product master data * set. After obtaining user input, the data set is locked * for exclusive access. A transaction starts, and * new values are added by a call to DBPUT. At the end * of the routine, the transaction is ended and locks * are released. * * ACCESS: Mode 1 - Shared Modify Access * * CALLED BY: Main Line * * CALLS: DBLOCK in mode 3 (unconditional) * DBBEGIN in mode 1 (transaction begin) * DBPUT in mode 1 (put) * DBEND in mode 1 (transaction end) * DBUNLOCK in mode 1 (unlock) BEGIN ROUTINE Product_Buffer is made up of: Stock# Description OBTAIN Stock# <---- user input OBTAIN Description <---- user input OBTAIN List <---- "@;" CALL DBLOCK (DBname, Product_Master, Mode3_Unconditional, Status) ERROR CHECKING OBTAIN Text <---- "Add entry to Product set Begin__" OBTAIN Textlen <---- 16 CALL DBBEGIN (DBname, Text, Mode1_Xbegin, Status, TextLen) ERROR CHECKING CALL DBPUT (DBname, Product_Master, Mode1_Put, Status, List, Product_Buffer) ERROR CHECKING OBTAIN Text <---- "Add entry to Product set End" OBTAIN Textlen <---- 14 CALL DBEND (DBname, Text, Mode1_Xend, Status, Textlen) ERROR CHECKING CALL DBUNLOCK (DBname, Product_Master, Mode1_Unlock, Status) ERROR CHECKING END ROUTINE


MPE/iX 5.5 Documentation