Building C and C++ routine code using sample bldrtn scripts
Building C and C++ routine source code is a subtask of creating C
and C++ routines. You can easily build C and C++ routines with the database sample build scripts
(Linux® and UNIX) and batch files (Windows).
The sample build scripts
can be used for source code with or without embedded SQL statements. The build scripts can
pre-compile, compile, and link C or C++ source code. The build scripts can also bind any packages
that are associated with the embedded SQL routine to the specified database.
Before you begin
The sample build-script for building C and C++ routines
is named
bldrtn
. The bldrtn
script
is located in the following database directories along with the sample
programs:- For C:sqllib/samples/c/
- For C++: sqllib/samples/cpp/
The
bldrtn
script can be used to build
a source code file that contains both procedure and function implementations. The bldrtn
script performs
the following tasks:- Establishes a connection with a user-specified database
- Precompiles the user-specified source code file
- Binds the package to the current database
- Compiles and links the source code to generate a shared library
- Copies the shared library to the database function directory on the database server
The
bldrtn
scripts accept two arguments:- The name of a source code file without any file extension
- The name of a database to which a connection is established
The database parameter is optional. If no database name is supplied, the program uses the default sample database. As routines must be built on the same instance where the database resides, no arguments are required for a user ID and password.
- Source code file that contains one or more routine implementations.
- The name of the database within the current database instance in which the routines are to be created.
Procedure
To build a source code file that contains one or more routine code implementations: