Once you have created the source code for your embedded SQL application, you must follow additional steps to build it. You should consider building 64-bit executables when developing new embedded SQL database applications. Along with compiling and linking your program, you must precompile and bind it.
The precompilation process converts embedded SQL statements into DB2® run-time API calls that a host language compiler can process. By default, a package is created at precompile time. Optionally, a bind file can be created at precompile time. The bind file contains information about the SQL statements in the application program. The bind file can be used later with the BIND command to create a package for the application.
Binding is the process of creating a package from a bind file and storing it in a database. The bind file must be bound to each database that needs to be accessed by the application. If your application accesses more than one database, you must create a package for each database.
To run applications written in compiled host languages, you must create the packages needed by the database manager at execution time. The following figure shows the order of these steps, along with the various modules of a typical compiled DB2 application.:
Since the SQL statements placed in an application are not specific to the host language, the database manager provides a way to convert the SQL syntax for processing by the host language. For C, C++, COBOL, or FORTRAN languages, this conversion is handled by the DB2 precompiler that is invoked using the PRECOMPILE (or PREP) command. The precompiler converts embedded SQL statements directly into DB2 run-time services API calls. When the precompiler processes a source file, it specifically looks for SQL statements and avoids the non-SQL host language.
Compiling and linking (steps 3 and 4) create the required object modules