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

264 Chapter6
Host Language Access
C
DBFIND in mode 1 (chained access)
DBGET in mode 5 (forward chained read)
DBUNLOCK in mode 1 (unlock)
Get_Error_And_Explain
*/
{
struct Lock_Descriptor_Type Lock_Descriptor;
struct Sales_Data_Set_Type Sales_Buffer;
short Search_Item_Value[3];
short Search_Item_Name[8];
short List[40];
short Dummy;
size_t srch_len = 6;
/* Prepare the lock descriptor buffer for obtaining item
level locks on the Sales data set.
*/
Lock_Descriptor.Num_Of_Elements = 1;
Lock_Descriptor.Length_Of_Descriptor = 21;
strcpy(Lock_Descriptor.Data_Set_Of_Descriptor,(char *)Sales_D_Set);
strcpy(Lock_Descriptor.Data_Item_Of_Descriptor,(char *)Purch_Date);
Lock_Descriptor.Relop_For_Data_Item[0] = Equal_Op[0];
Lock_Descriptor.Relop_For_Data_Item[1] = Equal_Op[1];
printf("Enter The Date of Purchase as (YYMMDD) >>> \n");
scanf("%6c", (char *)Search_Item_Value);
/* Request item level locks (mode 5) */
Mode = 5;
/* Append the user's input to the lock descriptor buffer */
strncpy(Lock_Descriptor.Value_For_Data_Item,
(char *)Search_Item_Value,srch_len);
/* Place item level locks on all entries identified by
the value in the Search_Item_Value
*/
DBLOCK(DBname,&Lock_Descriptor,&Mode,&Status);
if (Status.Condition != 0)
Get_Error_And_Explain();
Mode = 1;
strcpy((char *)Search_Item_Name, Purch_Date);
/* Locate the chain identified by the value in the
Search_Item_Value
*/
DBFIND(DBname,Sales_D_Set,&Mode,&Status,
Search_Item_Name, Search_Item_Value);
if (Status.Condition != 0)
{
if (Status.Condition == No_Chain_Head)
{
printf("***************************************\n");
printf("* No Such Entry in the Sales Dataset *\n");
printf("* Please Try Again. *\n");
printf("***************************************\n");
}
else
Get_Error_And_Explain();