Building CLI routines 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. The
batch file
bldrtn.bat
contains the commands to build CLI routines
(stored procedures and user-defined functions). bldrtn.bat
creates
a DLL on the server. It takes one parameter, represented inside the
batch file by the variable %1
, which specifies the
name of your source file. The batch file uses the source file name
for the DLL name.Procedure
To build the spserver
DLL from the source
file spserver.c
:
Results
Once you build the DLL spserver
, you can
build the CLI client
application spclient
that calls the routines within
it.
You can build spclient
by using the script
file, bldapp
.
To call the routines, run the sample client application by entering:
spclient
database userid password
where
- database
- Is the name of the database to which you want to connect.
The name could be
sample
, or its alias, or another database name. - userid
- Is a valid user ID.
- password
- Is a valid password.
The client application accesses the DLL, spserver
,
which executes the routines on the server database. The output is
returned to the client application.