Application Building Guide


DB2 API Applications

The DB2 AD Client includes sample programs that call DB2 APIs. The "Building Applications" chapters later in the book explain how to build the sample programs for the supported compilers using the DB2 application build files supplied with the DB2 AD Client for that platform. You can also use the makefiles that are supplied. Both the makefiles and the build 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.

The following sample program is used in this book to demonstrate the steps for building and running DB2 API applications using the supported programming languages. The steps you follow may vary, depending on your environment:

client
demonstrates the use of the following APIs: SET CLIENT, and QUERY CLIENT

Links to the source code of this program are available for the following languages:

C
client.c

C++
client.C

COBOL
client.cbl

For a detailed description of all DB2 API sample programs, see Sample Program Tables.

The source files for DB2 API sample programs, where supported, are in the appropriate programming language subdirectory of sqllib/samples (UNIX), and %DB2PATH%\samples (OS/2 and Windows 32-bit operating systems).

After you build the sample programs, they can be used as templates to create your own applications. You can build the DB2 API programs using either the makefile or the build files provided.
Note:When writing your API applications, all API input structures should be memset to 0 so that structure elements that are not explicitly set are initialized to 0. This is important when recompiling applications that have been coded against downlevel versions of APIs. When recompiling, the new definition of the structure is used but all the elements may not be initialized. The call to memset will ensure that they are initialized. Here is an example showing the input data structure, pLoadInStruct, memset to 0:
   memset( pLoadInStruct, 0, sizeof(pLoadInStruct) );

The following list points you to where you can find building information for the DB2 API applications for the DB2 supported platforms and compilers:

AIX
IBM C: "DB2 API and Embedded SQL Applications"

IBM C Set++: "DB2 API and Embedded SQL Applications"

IBM VisualAge C+ C+: "DB2 API Applications"

IBM COBOL: "DB2 API and Embedded SQL Applications"

Micro Focus COBOL: "DB2 API and Embedded SQL Applications"

HP-UX
HP C: "DB2 API and Embedded SQL Applications"

HP C++: "DB2 API and Embedded SQL Applications"

Micro Focus COBOL: "DB2 API and Embedded SQL Applications"

Linux
GNU/Linux gcc: "DB2 API and Embedded SQL Applications"

GNU/Linux gcc (C++): "DB2 API and Embedded SQL Applications"

OS/2
IBM VisualAge C++ Version 3: "DB2 API and Embedded SQL Applications"

IBM VisualAge C++ Version 4: "DB2 API Applications"

IBM VisualAge for COBOL: "Embedded SQL Applications"

Micro Focus COBOL: "DB2 API and Embedded SQL Applications"

Silicon Graphics IRIX
MIPSpro C: "DB2 API and Embedded SQL Applications"

MIPSpro C++: "DB2 API and Embedded SQL Applications"

Solaris
SPARCompiler C: "DB2 API and Embedded SQL Applications"

SPARCompiler C++: "DB2 API and Embedded SQL Applications"

Micro Focus COBOL: "DB2 API and Embedded SQL Applications"

Windows 32-bit Operating Systems
Microsoft Visual C++: "DB2 API and Embedded SQL Applications"

IBM VisualAge for C++ Version 3.5: "DB2 API and Embedded SQL Applications"

IBM VisualAge for C++ Version 4.0: "DB2 API Applications"

Micro Focus COBOL: "DB2 API and Embedded SQL Applications"

IBM VisualAge for COBOL: "DB2 API and Embedded SQL Applications"


[ Top of Page | Previous Page | Next Page ]