Default compilation order

After you have created the program file, you run the esql command on that file. By default, the preprocessor runs first and translates the embedded SQL statements in the program into function calls that communicate with the database server. The preprocessor produces a C source file and calls the C compiler. The C compiler then preprocesses and compiles your source file and links any other C source file, object file, or library file the same way as any other C program. If esql does not encounter errors in one of these steps, it generates an executable file. You can run the compiled program as you would any C program. When the program runs, it calls the library procedures; the library procedures set up communications with the database server to carry out the SQL operations.

The following figure illustrates the process by which the program becomes an executable program.
Figure 1: Relationship between and C


Important: Keep in mind that with the default order of compilation, esql handles preprocessor directives before it calls the C compiler. Therefore, the directives take effect before the C compiler performs any preprocessing. You cannot access definitions within C preprocessor directives, nor can you use the C preprocessor to perform conditional compilation of statements.