When you run the precompiler, the C/C++ precompiler translates the SQL statements embedded in the application program into calls of procedures of the precompiler runtime environment, and prepares the source code for the C/C++ compiler
The precompiler performs the following tasks:
· Generates the descriptor structure sqlda
· Generates the structure sqlca for database system messages
· Includes the standard header file cpc.h
· Checks the syntax of the embedded SQL statements
· Generates the precompiler log with any error messages and warnings
If you choose the precompiler option check , the precompiler checks the existence of the called database tables and columns, as well as the compatibility of the data types and the access privileges of the users. It does this by sending the embedded SQL statements to the parser or database kernel. A ROLLBACK resets the effects of all SQL statements executed in this way after the precompiler has completed its run.
Only the syntax can be checked for statements with components unknown to the precompiler. These can be, for example, dynamic SQL statements or CONNECT statements with host variables.
The SQL statements are executed in the order in which they appear in the source code, and not in the logical order of the program statements.
Before it can check the embedded SQL statements (with the check option), the precompiler must connect to the database instance. The following rules apply:
· If the first static SQL statement of a database session is not a CONNECT statement, then all user data of the XUSER user key DEFAULT applies.
· If the first static SQL statement of a database session is a CONNECT statement, then all data is taken from this statement, and any missing data from the XUSER user key DEFAULT.
· In the first database session, you can use appropriate precompiler options to override all user data.