Processing SQL statements by using the DB2 precompiler
The DB2® precompiler scans a program and copies all of the SQL statements and host variable information into a DBRM (database request module). The precompiler also returns source code that has been modified so that the SQL statements do not cause errors when you compile the program.
About this task
After the SQL statements and host variable information are copied into a DBRM and the modified source code is returned, you can compile and link-edit this modified source code.
Before you run the DB2 precompiler, use DCLGEN to obtain accurate SQL DECLARE TABLE statements. The precompiler checks table and column references against SQL DECLARE TABLE statements in the program, not the actual tables and columns.
DB2 does not need to be active when you precompile your program.
You do not need to precompile the program on the same DB2 subsystem on which you bind the DBRM and run the program. You can bind a DBRM and run it on a DB2 subsystem at the previous release level, if the original program does not use any properties of DB2 that are unique to the current release. You can also run applications on the current release that were previously bound on subsystems at the previous release level.
Procedure
To process SQL statements by using the DB2 precompiler:
Results
- The program consists of more than one data set or member.
- More than one data set or member contains SQL statements.
You must precompile the contents of each data set or member separately, but the prelinker must receive all of the compiler output together.
JCL procedure DSNHCPP2, which is in member DSNTIJMV of data set DSN1010.SDSNSAMP, shows you one way to do this for C++.