Assembler, C, C++, COBOL, PL/I, and REXX programming examples

You can write DB2® programs in assembler language, C, C++, COBOL, Fortran, PL/I, or REXX. These programs can access a local or remote DB2 subsystem and can execute static or dynamic SQL statements.

This information contains several such programming examples.

To prepare and run these applications, use the JCL in DSN1010.SDSNSAMP as a model for your JCL.

Conventions used in examples of coding SQL statements

The examples in this information use certain conventions and assumptions. Some of the examples vary from these conventions. Exceptions are noted where they occur.

The SQL statements in this information use the following conventions:

  • The SQL statement is part of a C or COBOL application program. Each SQL example is displayed on several lines, with each clause of the statement on a separate line.
  • The use of the precompiler options APOST and APOSTSQL are assumed (although they are not the defaults). Therefore, apostrophes (') are used to delimit character string literals within SQL and host language statements.
  • The SQL statements access data in the sample tables provided with DB2. The tables contain data that a manufacturing company might keep about its employees and its current projects.
  • An SQL example does not necessarily show the complete syntax of an SQL statement.
  • Examples do not take referential constraints into account.