Contents Index Single-file build procedure Data Access Using Embedded SQL

UltraLite Embedded SQL User's Guide
  Building Embedded SQL Applications

Configuring development tools for embedded SQL development


Many development tools use a dependency model, sometimes expressed as a makefile, in which the timestamp on each source file is compared with that on the target file (object file, in most cases) to decide whether the target file needs to be regenerated.

With UltraLite development, a change to any SQL statement in a development project means that the generated code needs to be regenerated. Changes are not reflected in the timestamp on any individual source file because the SQL statements are stored in the reference database,.

This section describes how to incorporate UltraLite application development, specifically the SQL preprocessor and the UltraLite generator, into a dependency-based build environment. The specific instructions provided are for Visual C++, and you may need to modify them for your own development tool.

The UltraLite plug-in for Metrowerks CodeWarrior automatically provides Palm Computing platform developers with the techniques described here. For information on this plug-in, see Developing UltraLite applications with Metrowerks CodeWarrior.

or a tutorial describing details for a very simple project, see Tutorial: Build an Application Using Embedded SQL.

SQL preprocessing 

The first set of instructions describes how to add instructions to run the SQL preprocessor to your development tool.

To add embedded SQL preprocessing into a dependency-based development tool

  1. Add the .sqc files to your development project.

    The development project is defined in your development tool. It is separate from the UltraLite project name used by the UltraLite generator.

  2. Add a custom build rule for each .sqc file.

  3. Compile the .sqc files, and add the generated .c files to your development project.

    You need to add the generated files to your project even though they are not source files, so that you can set up dependencies and build options.

  4. For each generated .c file, set the preprocessor definitions.

UltraLite code generation 

The following set of instructions describes how to add UltraLite code generation to your development tool.

To add UltraLite code generation into a dependency-based development environment

  1. Add a dummy file to your development project.

    Add a file named, for example, uldatabase.ulg, in the same directory as your generated files.

  2. Set the build rules for this file to be the UltraLite generator command line.

    In Visual C++, use a command of the following form (which should be all on one line):

    "%asany9%\win32\ulgen.exe" -q -c "connection-string" $(InputName) $(InputName).c

    where asany9 is an environment variable that points to your SQL Anywhere installation directory, connection-string is a connection to your reference database, and InputName is the UltraLite project name, and should match the root of the text file name. The output is $(InputName).c.

  3. Set the dummy file to depend on the output files from the preprocessor.

    In Visual C++, click Dependencies on the custom build page, and enter the names of the generated .c files produced by the SQL preprocessor.

    This instructs Visual C++ to run the UltraLite generator after all the necessary embedded SQL files have been preprocessed.

  4. Compile your dummy file to generate the .c file that implements the UltraLite database.

  5. Add the generated UltraLite database file to your project and change its C/C++ settings.

  6. Add the UltraLite imports library to your object/libraries modules list.

    In Visual C++, go to the project settings, choose the Link tab, and add the following to the Object/libraries module list for Windows development.

    $(asany9)\ultralite\win32\386\lib\ulimp.lib

    For other targets, choose the appropriate import library.

  7. When you alter any SQL statements in the reference database, touch the dummy file, to update its timestamp and force the UltraLite generator to be run.


Contents Index Single-file build procedure Data Access Using Embedded SQL