Examples of how to use XL C/C++ programs to request DB2 services
The examples in this section demonstrate how to code C and C++ programs with embedded SQL statements. You can use them with either the XL C/C++ DB2® coprocessor or the DB2 C/C++ precompiler.
Example CCNGDB4 demonstrates how to code a C program with embedded SQL statements. In Figure 1, a program CCNGDB4 creates a table called CTAB1, inserts literal values into the table, and drops the table. You can use this example either by compiling the program with the SQL option in effect or by running the program through the DB2 C/C++ precompiler, and then compiling the generated code with the NOSQL option in effect.
Figure 1. Using DB2 with C
|
|
Figure 2 is a C++ code example with embedded SQL statements. The sample code creates, populates, updates, and drops a table called CTAB1V. You can use this example either by compiling the program with the SQL option in effect or by running the program through the DB2 C/C++ precompiler, and then compiling the generated code with the NOSQL option in effect.
Figure 2. Using DB2 with C/C++
|
|
|