Source files that contain embedded SQL statements must be precompiled before they can be used as ordinary C or C++ source files. If you are using DB2, you can run the DB2 SQL precompiler as a build extension during a build.
DB2 must be running on your workstation when you use the DB2 SQL precompiler in a build. If DB2 is not active:
To build your project, you can open the VisualAge C++ IDE or enter the vacbld command in the VisualAge C++ command line window, in the usual manner.
To precompile embedded SQL during a build, specify the C or C++ source files that contain the embedded SQL as source files for the build:
If your source files have different file extensions, you must explicitly specify that the type is sqc for C and sqx for C++. When the build process encounters a file of type sqc or sqx, and DB2 is installed, the DB2 SQL precompile function is run automatically.
You must apply the following option to source files with embedded SQL:
You can optionally apply the following options to source files with embedded SQL:
The DB2 precompile build extension produces the following files:
You can list the files produced by the build extension as sources in your configuration file. For example, you can perform a DB2 SQL precompile to create .c or .cxx files from .sqc or .sqx source files, and use the .c or .cxx files as sources for the build.You can even specify the .sqc or .sqx files directly as sources for the executable file or libraries that are targets of the build.
For example, the following lines from a configuration file build an executable target, MyTown.exe, from one import library and two C++ source files that contain embedded SQL.
option SQLTargetDB("towndb1") {
target "MyTown.exe" {
option SQLTargetDB("towndb2") {
source "downTown.sqx"
}
source "upTown.sqx", "db2api.lib"
}
}
In the lines above, the file downTown.sqx is precompiled with option SQLTargetDB("towndb2"). The file upTown.sqx is precompiled with option SQLTargetDB("towndb1"). To create MyTown.exe, files downTown.cxx, upTown.cxx, and db2api.lib are used.
![]()
Configuration Files
Build Extensions and Specification
(.ice) Files
Source Files That Contain
Embedded SQL
![]()
Add or Change Source
Files
Override the Default Type of a Source File
Build
![]()
Build Extensions Supplied with
VisualAge C++
Types of Source Files
