TurboIMAGE/XL Database Management System Reference Manual MPE/iX V6.5 (30391-90011)

298 Chapter6
Host Language Access
Pascal
Retrieving All the Records on a Chain (with Item Level Locking)
This procedure implements the Get_Sales_For_Date routine of the sample program.
Chained access is achieved using a call to DBFIND. The search item used for this call is
Purch-Date. An item level lock is obtained on the value of the search item before the
DBFIND call. After that, individual chain items are retrieved, until the end of chain is
encountered. This is done using multiple calls to the DBGET procedure.
The routine traps two exceptional conditions:
1. Status condition 17 from the DBFIND call, indicating that the chain head cannot be
located.
2. Status 15 from the DBGET call, indicating the end of chain.
The status interpretation routine permits you to either abort or continue with the
execution of the program after viewing all error messages.
$Page$
Procedure Get_Sales_For_Date;
(* Access : Mode 1 - Shared Modify Access
The Orders database was opened in mode 1.
Called By: Main Line
Calls : DBLOCK in mode 5 (unconditional item level locking)
DBFIND in mode 1 (chained access)
DBGET in mode 5 (forward chained read)
DBUNLOCK in mode 1 (unlock)
Get_Error_And_Explain *)
Var
Lock_Descriptor_Array : Lock_Descriptor_Sales_Array_Type;
Sales_Detail : Data_Set_Name_Type;
Search_Item_Name : Data_Item_Name_Type;
Search_Item_Value : Packed Array [1..6]of Char;
Sales_Buffer : Sales_Data_Set_Type;
Not_Used_Parm : Shortint;
Mode1_Chained_Read : Shortint;
Mode5_Unconditional : Shortint;
Mode5_Forward : Shortint;
Mode1_Unlock : Shortint;
Begin
(* Prepare the lock descriptor buffer for obtaining item level *)
(* locks on the Sales data set. *)
With Lock_Descriptor_Array Do
Begin
Num_Of_Elements := 1;
With Lock_Descriptor_Sales Do
Begin
Length_Of_Descriptor := 21;
Data_Set_Of_Descriptor :='SALES;';
Data_Item_Of_Descriptor :='PURCH-DATE;';
Relative_Operator :=' =';
End;
End;
Prompt (' Enter The Date of Purchase as (YYMMDD) >>> ');