Precompiling programs with SQL statements
You must precompile and compile an application program containing embedded SQL statements before you can run it. Precompiling such programs is done by an SQL precompiler.
The SQL precompiler scans each statement of the application program source and does the following things:
- Looks for SQL statements and for the definition of host variable names
- Verifies that each SQL statement is valid and free of syntax errors
- Validates the SQL statements using the description in the database
- Prepares each SQL statement for compilation in the host language
- Produces information about each precompiled SQL statement
Application programming statements and embedded SQL statements are the primary input to the SQL precompiler. The SQL precompiler assumes that the host language statements are syntactically correct. If the host language statements are not syntactically correct, the precompiler might not correctly identify SQL statements and host variable declarations.
The SQL precompile process produces a listing and a temporary source file member. It can also produce the SQL package depending on what is specified for the OPTION and RDB parameters of the precompiler command.
- Listing
The output listing is sent to the printer file specified by the PRTFILE parameter of the CRTSQLxxx command.
- Temporary source file member
Source statements processed by the precompiler are written to QSQLTEMP in the QTEMP library (QSQLTEMP1 in the QTEMP library for programs created using CRTSQLRPGI).
- SQL package creation
An object called an SQL package can be created as part of the precompile process when the CRTSQLxxx command is compiled.
- Precompiler commands
The DB2® UDB Query Manager and SQL Development Kit licensed program has seven precompiler commands, one for each of the host languages.
Parent topic:
Preparing distributed relational database programs
Related reference
Compiling an application program