Table of Contents
Programming with INFORMIX-ESQL/C
What Is INFORMIX-ESQL/C?
ESQL/C is an SQL application programming interface (API) that enables you to embed Structured Query Language (SQL) statements directly into a C program. The ESQL/C preprocessor, which the esql command calls, converts each SQL statement and all Informix-specific code to C.
To access a database server through an ESQL/C application
- Write embedded SQL statements and calls to ESQL/C library functions into your C code to create an ESQL/C program.
- Convert the ESQL/C program to a C executable file with the esql command.
Compiling an ESQL/C Program: You type the esql command to compile your ESQL/C program. The esql command passes your ESQL/C source file to the ESQL/C preprocessor and to the C compiler. It passes along options that are specific to both the ESQL/C preprocessor and the C compiler to preprocess, compile, and link your ESQL/Cprogram.
The esql command follows these steps to carry out the conversion:
- In Stage 1, the ESQL/C preprocessor performs the following steps:
- Incorporates header files into the source file when it processes all include directives ($include and EXEC SQL include statements)
- Creates or removes compile-time definitions when it processes all define ($define and EXEC SQL define) and undef ($undef and EXEC SQL undef) directives
- In Stage 2, the ESQL/C preprocessor processes any conditional compilation directives (ifdef, ifndef, else, elif, endif) and translates embedded SQL statements to ESQL/C function calls and special data structures.
Stages 1 and 2 mirror the preprocessor and compiler stages of the C compiler. Successful completion of the preprocessing step yields a C source file (.c extension).
Default Compilation Order
ESQL/C source program -> ESQL/C preprocessor -> C source program with SQL statements and ESQL/C calls -> C language preprocessor and compiler -> Executable program