IBM Books

Building Applications for UNIX** Environments


Chapter 3. Introduction to Embedded SQL Applications

Each DB2 SDK includes sample programs that embed SQL statements. Chapters 4 through 8 explain how to build the sample programs for the supported compilers using script files supplied with the DB2 SDK for that platform. You can also use the makefiles that are supplied. Both the makefiles and the script files show you the compiler options you can use. These options are defined for each platform's supported compilers in the appropriate chapter. You might need to modify the options for your environment.

When you run a script file to build a sample program containing embedded SQL, the script file executes the following steps:

For User-Defined Functions (UDFs), you do not need to connect to a database or precompile and bind the program.

The following are the sample programs used to demonstrate the steps for building and running your applications using the supported programming languages. The steps you follow may vary, depending on your environment:

updat
uses static SQL to update a database.

outcli
is the client program of a client/server example; the server program is outsrv.

outsrv
is the server program of a client/server example; the client program is outcli.

udf
creates a library of user-defined functions (UDFs); calludf uses these functions.

calludf
uses the functions created by udf.

thdsrver
demonstrates thread creation and management; only available in the C language.

For a more detailed description of these sample programs, see Table 3.

The source files for these sample programs, where supported, are in the appropriate programming language subdirectory of sqllib/samples:

C
sqllib/samples/c

C++
sqllib/samples/cpp

IBM COBOL
sqllib/samples/cobol

Micro Focus COBOL
sqllib/samples/cobol_mf

Fortran
sqllib/samples/fortran

After you build the sample programs, they can be used as templates to create your own applications. This can be done by modifying the sample programs with your own SQL statements. You can build your programs using either the makefile or the script files provided.

"Sample Programs" lists all of the sample programs. The Embedded SQL Programming Guide explains how the samples containing embedded SQL work.
Note:It is recommended that, before you alter or build the sample programs, you copy them from sqllib/samples to your own working directory.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]

[ DB2 List of Books | Search the DB2 Books ]