DB2 10.5 for Linux, UNIX, and Windows

Building DB2CI applications

You can build DB2CI applications using an existing Oracle Call Interface (OCI) application and the bldapp script file.

Before you begin

  • You must have a DB2® database with the same structure as the Oracle database used by your existing OCI application.
  • You must have installed the IBM® Data Server Client.

About this task

DB2 samples provides a script called bldapp for compiling and linking applications that use OCI functions supported by the IBM Data Server Driver for DB2CI. It is located in the DB2DIR\samples\db2ci or DB2DIR/samples/db2ci directories, along with sample programs. DB2DIR represents the location where your DB2 copy is installed.

The bldapp script file takes up to four parameters. The first parameter, $1, specifies the name of your source file. The additional parameters are only required to build embedded SQL programs that requires a connection to the database: the second parameter, $2, specifies the name of the database to which you want to connect; the third parameter, $3, specifies the user ID for the database, and $4 specifies the password. If the program contains embedded SQL, indicated by the .sqc extension, then the embprep script is called to precompile the program, producing a program file with a .c extension.

Restriction

  • Ensure that your existing OCI application only has calls to OCI functions supported by the DB2CI driver. See IBM Data Server Driver for DB2CI for a complete list of supported OCI functions.

Procedure

  1. If you are building your DB2CI application using an existing OCI application, ensure that you specify the db2ci.h include file.
  2. Build your DB2CI application with the bldapp script file The following example shows how to build the sample program tbinfo from the source file tbinfo.c on Linux and UNIX operating systems:
     cd $INSTHOME/sqllib/samples/db2ci
     bldapp tbinfo
    The result is an executable file, tbinfo.
  3. Run the executable file generated in the previous step by entering the executable name as follows:
       tbinfo