Compiling and link-editing an application

If you use the DB2® precompiler, your next step in the program preparation process is to compile and link-edit your program. As with the precompile step, you have a choice of methods.

About this task

You can use one of the following methods to compile and link-edit an application:

If you use the DB2 coprocessor, you process SQL statements as you compile your program. For programs other than C and C++ programs, you must use JCL procedures when you use the DB2 coprocessor. For C and C++ programs, you can use either JCL procedures or UNIX System Services on z/OS® to invoke the DB2 coprocessor.

The purpose of the link-edit step is to produce an executable load module. To enable your application to interface with the DB2 subsystem, you must use a link-edit procedure that builds a load module that satisfies environment-specific requirements.

TSO and batch: Start of changeInclude the DB2 TSO attachment facility language interface module (DSNELI) or DB2 call attachment facility language interface module (DSNALI) or the Universal Language Interface module (DSNULI).End of change
IMS: Include the DB2 IMS™ language interface module (DFSLI000), which contains the DSNHLI entry point. Also, the IMS RESLIB must precede the SDSNLOAD library in the link list, JOBLIB, or STEPLIB concatenations.

IMS and DB2 share a common alias name, DSNHLI, for the language interface module. You must do the following when you concatenate your libraries:

  • If you use IMS, be sure to concatenate the IMS library first so that the application program compiles with the correct IMS version of DSNHLI.
  • If you run your application program only under DB2, be sure to concatenate the DB2 library first.
CICS: Start of changeInclude the DB2 CICS® language interface module (DSNCLI) or the Universal Language Interface module (DSNULI). You can link DSNCLI with your program in either 24-bit or 31-bit addressing mode (AMODE=31), but DSNULI must be linked with your program in 31-bit addressing mode (AMODE=31). If your application runs in 31-bit addressing mode, you should link-edit the DSNCLI or DSNULI stub to your application with the attributes AMODE=31 and RMODE=ANY so that your application can run above the 16-MB line.End of change

You also need the CICS EXEC interface module that is appropriate for the programming language. CICS requires that this module be the first control section (CSECT) in the final load module.

The size of the executable load module that is produced by the link-edit step varies depending on the values that the SQL statement processor inserts into the source code of the program.

Link-editing a batch program: DB2 has language interface routines for each unique supported environment. DB2 requires the IMS language interface routine for DL/I batch. You need to have DFSLI000 link-edited with the application program.
Related reference:
DSNH (TSO CLIST)

Related information