TurboIMAGE/XL Database Management System Reference Manual MPE/iX V6.5 (30391-90011)
Chapter 6 263
Host Language Access
C
Opening the Database
This paragraph implements the OPEN-THE-DATABASE routine of the sample program in C.
All required values, such as the password, are defined in the "static char" section of the
program. Note that the password DO-ALL establishes user class number 18. The password
DO-ALL is followed by a semicolon because it is less than eight characters long; a blank
can be substituted for the semicolon. OPEN-THE-DATABASE uses open mode 1, which is the
shared modify access mode. Error trapping is done by referring all non-zero conditions to
the GET-ERROR-AND-EXPLAIN procedure.
Open_The_Database()
{
/*
ACCESS : Mode 1 - Shared Modify Access (SMA) with locking required
Called By: Main Line
Calls : DBOPEN in mode 1 (SMA)
Get_Error_And_Explain
*/
Mode =1;
DBOPEN(DBname,Password,&Mode,&Status);
if (Status.Condition != 0)
Get_Error_And_Explain();
}
Retrieving All the Records on a Chain (with Item Level Locking)
This paragraph implements the GET-SALES-FOR-DATE routine of the sample program.
Chain access is achieved using a call to DBFIND to determine the location of the first and
last entries in the chain. 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 the 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 the chain.
The status interpretation routine permits you to either abort or continue with the
execution after viewing all error messages.
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)