Compiling and linking source files containing embedded SQL

You can precompile embedded SQL programs using the PRECOMPILE command. You must then compile and link the resultant modified source files with the appropriate host language compiler.

About this task

When precompiling embedded SQL source files, the PRECOMPILE command generates modified source files with a file extension applicable to the programming language.

Compile the modified source files (and any additional source files that do not contain SQL statements) using the appropriate host language compiler. The language compiler converts each modified source file into an object module.

Refer to the programming documentation for your operating platform for any exceptions to the default compiler options. Refer to your compiler's documentation for a complete description of available compiler options.

The host language linker creates an executable application. For example:
  • On Windows operating systems, the application can be an executable file or a dynamic link library (DLL).
  • On UNIX and Linux® based operating systems, the application can be an executable load module or a shared library.
Note: Although applications can be DLLs on Windows operating systems, the DLLs are loaded directly by the application and not by the Db2® database manager. On Windows operating systems, the database manager loads embedded SQL stored procedures and user-defined functions as DLLs.
To create the executable file, link the following objects:
  • User object modules, generated by the language compiler from the modified source files and other files not containing SQL statements.
  • Host language library APIs, supplied with the language compiler.
  • The database manager library containing the database manager APIs for your operating environment. Refer to the appropriate programming documentation for your operating platform for the specific name of the database manager library you need for your database manager APIs.