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

262 Chapter6
Host Language Access
C
Obtaining Error Messages and Explanations
The following paragraph implements the GET-ERROR-AND-EXPLAIN routine of the sample
program. This routine calls DBEXPLAIN and DBERROR. DBEXPLAIN interprets the contents
of the status parameter and prints a message on $STDLIST. DBERROR returns a message
in the ERROR-BUFFER, explaining the condition code returned by TurboIMAGE/XL. At
the end the routine, users can choose to abort or continue the execution of this program.
/* Beginning of subroutines */
Get_Error_And_Explain()
{
/*
Access : Mode 1 - Shared Modified Access
The Orders database was opened in mode 1
Called by: Open_The_Database
Get_Sales_For_Date
Get_A_Product_Record
List_All_Customers
Add_A_Product
Update_A_Customer
Delete_A_Product
Rewind_Customer_Set
Get_Data_Item_Info
Close_The_Database
Calls : DBERROR
DBEXPLAIN
*/
short Error_Buffer[80];
short Error_Length;
int Answer;
DBERROR(&Status,Error_Buffer,&Error_Length);
printf("-------------------------------------------\n");
printf("%.*s\n",Error_Length, (char *)Error_Buffer);
printf("-------------------------------------------\n");
DBEXPLAIN(&Status);
Answer=0;
printf("---Enter, <1> to ABORT..., <2> to Continue >\n");
scanf("%d",&Answer);
if (Answer != 1)
printf(" Continuing .........\n");
else
exit(0);
}