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
embprep
file. Theembprep
file precompiles the source file and binds the program to the database. You use thecli.icc
configuration 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.icc
file as follows:- Set the CLI environment
variable to the program name by entering:
export CLI=dbusemx
- If you have a
cli.ics
file in your working directory, produced by building a different program with thecli.icc
orcliapi.icc
file, delete thecli.ics
file with this command:
An existingrm cli.ics
cli.ics
file 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
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
- If connecting to the sample database on the same instance, enter: