DB2 Version 9.7 for Linux, UNIX, and Windows

Building CLI applications on UNIX

DB2® provides build scripts for compiling and linking CLI programs. These are located in the sqllib/samples/cli directory, along with sample programs that can be built with these files. The script file bldapp contains the commands to build a CLI application. It takes up to four parameters, represented inside the script file by the variables $1, $2, $3, and $4. The parameter, $1, specifies the name of your source file. This is the only required parameter, and the only one needed for CLI applications that do not contain embedded SQL. Building embedded SQL programs requires a connection to the database so three optional parameters are also provided: 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.

About this task

The following examples show you how to build and run CLI applications. To build the sample program tbinfo from the source file tbinfo.c, enter:
 
   bldapp tbinfo
The result is an executable file, tbinfo. You can run the executable file by entering the executable name:
   tbinfo

Procedure

Results