Building CLI applications on Windows
Db2®
provides batch files 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.
About this task
The batch file bldapp.bat contains the
commands to build a CLI program. It takes up to four parameters, represented inside
the batch 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 programs 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 or .sqx extension, then the embprep.bat batch file is called to precompile the program,
producing a program file with either a .c or a .cxx extension.
The following examples show you how to build and run CLI applications.
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- Building and running embedded SQL applications
There are three ways to build the embedded SQL application,
dbusemx, from the source filedbusemx.sqc: