Building CLI applications with configuration files

The configuration file, cli.icc, in sqllib/samples/cli allows you to build CLI programs.

Procedure

To use the configuration file to build the CLI sample program tbinfo from the source file tbinfo.c:

  1. Set the CLI environment variable:
      export CLI=tbinfo
  2. If you have a cli.ics file in your working directory, produced by building a different program with the cli.icc file, delete the cli.ics file with this command:
       rm cli.ics
    An existing cli.ics file produced for the same program you are going to build again does not have to be deleted.
  3. Compile the sample program by entering:
       vacbld cli.icc
    Note: The vacbld command is provided by VisualAge® C++.
    The result is an executable file, tbinfo. You can run the program by entering the executable name:
       tbinfo

Results

Building and running embedded SQL applications

You use the configuration file after the program is precompiled with the embprep file. The embprep file precompiles the source file and binds the program to the database. You use the cli.icc configuration file to compile the precompiled file.

There are three ways to precompile the embedded SQL application, dbusemx, from the source file dbusemx.sqc:
  • If connecting to the sample database on the same instance, enter:
       embprep dbusemx
  • If connecting to another database on the same instance, also enter the database name:
       embprep dbusemx database
  • If connecting to a database on another instance, also enter the user ID and password of the database instance:
       embprep dbusemx database userid password

The result is a precompiled C file, dbusemx.c.

After it is precompiled, the C file can be compiled with the cli.icc file as follows:
  1. Set the CLI environment variable to the program name by entering:
       export CLI=dbusemx
  2. If you have a cli.ics file in your working directory, produced by building a different program with the cli.icc or cliapi.icc file, delete the cli.ics file with this command:
       rm cli.ics
    An existing cli.ics file produced for the same program you are going to build again does not have to be deleted.
  3. Compile the sample program by entering:
       vacbld cli.icc
There are three ways to run this embedded SQL application:
  • If accessing the sample database on the same instance, simply enter the executable name:
       dbusemx
  • If accessing another database on the same instance, enter the executable name and the database name:
       dbusemx database
  • If accessing a database on another instance, enter the executable name, database name, and user ID and password of the database instance:
       dbusemx database userid password