Building IBM® COBOL routines on AIX®

You can use the provided build scripts for compiling and linking COBOL embedded SQL and Db2® administrative API programs. The scripts are in the sqllib/samples/cobol directory. The directory also contains sample programs that you can build with these files.

You can find the commands to build routines, such as stored procedures, in the bldrtn script. You can find this script in the sqllib/samples/cobol directory. The bldrtn script compiles the routines into a shared library that can be called by a client application.

About this task

The first parameter, $1, specifies the name of your source file. The second parameter, $2, specifies the name of the database to which you want to connect. Since the shared library must be built on the same instance where the database resides, there are no parameters for user ID and password.

Only the first parameter, source file name, is required. The script uses the source file name, $1, for the shared library name. Database name is optional. If no database name is supplied, the program uses the default sample database.

To build the sample program outsrv from the source file outsrv.sqb, connecting to the sample database, enter:
   bldrtn outsrv
If connecting to another database, also include the database name:
   bldrtn outsrv database
The script file copies the shared library to the server in the path sqllib/function.

Once you build the routine shared library, outsrv, you can build the client application, outcli, that calls the routine within the library. You can build outcli using the script file bldapp.

To call the routine, run the sample client application by entering:
   outcli database userid password
where
database
Is the name of the database to which you want to connect. The name can be sample, or its remote alias, or some other name.
userid
Is a valid user ID.
password
Is a valid password for the user ID.

The client application accesses the shared library, outsrv, and executes the routine of the same name on the server database, and then returns the output to the client application.