TurboIMAGE/XL Database Management System Reference Manual MPE/iX V6.5 (30391-90011)
260 Chapter6
Host Language Access
C
C
This section shows, in C, portions of the model program presented at the beginning of this
chapter. The examples perform specific tasks to illustrate the use of TurboIMAGE/XL
intrinsics. The C example does not illustrate everything in the COBOL example. Some
blocks of code may be appropriate only if expanded to a full program.
Data items are defined at the beginning of the sample program. TurboIMAGE/XL
intrinsics must be declared for C as external procedures. The procedure name is identified
by the word "Intrinsic."
Type declarations declare names for data structure forms that will be used in allocating
variables. Variable declarations allocate the variables of the program. Variables are
defined with precise types or forms. C string literals are delimited with double quotation
marks (" "). Field and record names are separated with a dot (.) when referenced (for
example, base_name.baseid).
NOTE
Because the Schema Processor, DBSCHEMA, upshifts alphabetic characters,
programs must specify data set and data item names in all uppercase
characters. Take note of this because C does not require that you use
uppercase characters.
For information on TurboIMAGE/XL data item lengths and type designators, refer to
chapter 3. Tables 3-2 and 3-3 show the TurboIMAGE/XL type designators, sub-item
lengths, and data types typically used to process them in C.
NOTE
All parameters must be on halfword boundaries.
Defining Data Types, Variables, and Intrinsics
The following is part of the C example program; it defines type declarations, variable
declarations, and TurboIMAGE/XL intrinsics.
#pragma list off
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#pragma list on
/* Define all TurboIMAGE/XL procedure calls that */
/* will be used in your application program */
#pragma intrinsic DBBEGIN, DBEND, DBOPEN, DBCLOSE, DBGET, DBPUT,DBFIND, DBINFO
#pragma intrinsic DBEXPLAIN, DBERROR, DBDELETE, DBUPDATE, DBLOCK,DBUNLOCK
/* Define all your TurboIMAGE/XL constants */
#define End_Of_Chain 15 /* For DBGET Mode 5 */
#define End_Of_Data_Set 11 /* For DBGET Mode 2 */
#define No_Chain_Head 17 /* For DBFIND */
#define No_Such_Entry 17 /* For DBGET Mode 7 */
#define Entry_Has_No_Data 17 /* For DBGET Mode 4 */