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:
Results
- Building and running embedded SQL applications
You use the configuration file after the program is precompiled with the
embprepfile. Theembprepfile precompiles the source file and binds the program to the database. You use thecli.iccconfiguration file to compile the precompiled file.There are three ways to precompile the embedded SQL application,dbusemx, from the source filedbusemx.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 thecli.iccfile as follows:- Set the CLI environment
variable to the program name by entering:
export CLI=dbusemx - If you have a
cli.icsfile in your working directory, produced by building a different program with thecli.iccorcliapi.iccfile, delete thecli.icsfile with this command:
An existingrm cli.icscli.icsfile produced for the same program you are going to build again does not have to be deleted. - Compile the sample program by entering:
vacbld cli.icc
There are three ways to run this embedded SQL application:- If accessing the
sampledatabase 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
- If connecting to the sample database on the same instance, enter: