Db2 coprocessor
When you use the Db2® coprocessor (called SQL statement coprocessor by Db2), the compiler handles your source programs that contain embedded SQL statements without your having to use a separate precompile step.
To use the Db2 coprocessor, specify the SQL compiler
option.
When the compiler encounters SQL statements in the source program,
it interfaces with the Db2 coprocessor. All text between EXEC SQL and END-EXEC statements
is passed to the coprocessor. The coprocessor takes appropriate
actions for the SQL statements and indicates to the compiler which
native COBOL statements to generate for them.
Although the use of a separate precompile step continues to be supported, it is recommended that you use the coprocessor instead:
- Interactive debugging with Debug Tool is enhanced when you use the coprocessor because you see the SQL statements (not the generated COBOL source) in the listing.
- The COBOL compiler listing includes the error diagnostics (such as syntax errors in the SQL statements) that the Db2 coprocessor generates.
- Certain restrictions on the use of COBOL language that apply when
you use the precompile step do not apply when you use the Db2 coprocessor.
With the coprocessor:
- You can use SQL statements in any nested program. (With the precompiler, SQL statements are restricted to the outermost program.)
- You can use SQL statements in copybooks.
REPLACEstatements work in SQL statements.
Compiling with the Db2 coprocessor generates a Db2 database request
module (DBRM) along with the usual COBOL compiler outputs such as
object module and listing. The DBRM writes to the data set that you
specified in the DBRMLIB DD statement in the JCL
for the COBOL compile step. As input to the Db2 bind process, the DBRM data
set contains information about the SQL statements and host variables
in the program.