Preprocessing the ESQL Source Files
After you write your ESQL source files, preprocess them using the SQL preprocessor (
sqlcpp
). The preprocessor creates a pure C source file for each ESQL source file that it processes.NOTE: Complete this step only for ESQL source files that contain static and dynamic Progress/ESQL statements. Files that only contain calls to dynamic ESQL-LIB functions do not require preprocessing. However, you must ensure that any files you do not preprocess contain any necessary data declarations that the preprocessor provides.As it generates output, the preprocessor:
- Inserts the #include C preprocessor directive to specify the
proesql.h
header file and any data declarations required for cursors or other identifiers specified in Progress/ESQL statements.- Replaces ESQL statements with ESQL-LIB function calls and data references. The ESQL statements are not deleted, but commented out so you can see how each ESQL statement is converted to ESQL-LIB function calls and data assignments.
- Optionally inserts additional comments that contain readable representations of certain function parameter assignments, such as the static ESQL statements assigned to character arrays in generated function calls.
- Optionally precompiles any static ESQL statements in your application (except for Data Definition Language (DDL) statements). Precompilation generates a Progress r-code file for each SQL statement. R-code files contain the canonical (parsed and semantically structured) run code that Progress actually executes at run time for the specified SQL statements. If you do not precompile, Progress compiles the SQL statements when the application executes, at a cost in execution speed.
If you precompile, run all necessary database servers and provide the command line database connection parameters that enable the preprocessor to connect to the database(s) that your application accesses at run time. The preprocessor acts as a Progress database client and invokes the Progress Compiler to compile your SQL statements with these databases.
Figure 1–5 and Figure 1–6 demonstrate the differences between C source files preprocessed without precompilation and with it. The bold code shows the ESQL-LIB function calls.
Preprocessing Without Precompilation
Figure 1–5 shows the fragment from Figure 1–4 after preprocessing without precompilation.
Figure 1–5: Preprocessed Source File Fragment (Not Precompiled)
Without precompilation, each ESQL-LIB function is passed either a character string that contains the text of the corresponding SQL statement (sqltxt in the figure) or a null string, depending on the function.
Preprocessing with Precompilation
Figure 1–6 shows the fragment in Figure 1–4 after preprocessing with precompilation. The bold code shows the ESQL-LIB function calls.
Figure 1–6: Preprocessed Source File Fragment (Precompiled)
With precompilation, the preprocessor passes the r-code filename created to execute the corresponding SQL statement to each ESQL-LIB function.
Working with Preprocessor Output
The preprocessor generates a C source file with the same name as the ESQL source file but with a different extension. (By convention, the ESQL source file extension is
.cc
, but can be any value subject to your operating system naming requirements.) For example, if you preprocess an ESQL source file namedesqltest.cc
, the preprocessor generates a C source file namedesqltest.c
.Although you can view your preprocessed source file to understand how it works, do not modify it.
- Each time you preprocess your ESQL application during the development cycle, a new preprocessed source file is created. This can overwrite your modifications.
- If you incorrectly modify ESQL function calls or variable assignments, you could corrupt your database.
- Calling sequences that the preprocessor generates might change with future releases.
For more information on using the SQL preprocessor, see Building and Running ESQL Applications."
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |