UltraLite Embedded SQL User's Guide
Building Embedded SQL Applications
This section describes a general build procedure for UltraLite embedded SQL applications. You can use a simpler modification if your application uses only a single .sqc file. For more information, see Single-file build procedure.
This section assumes a familiarity with the overall embedded SQL development model. For more information, see Using UltraLite Static Interfaces.
You can find a makefile that uses this process in the Samples\UltraLite\ESQLSecurity directory. You require the separately-licensable transport-layer security option to build that sample.
For information on obtaining the transport-layer security option, see the card in your SQL Anywhere package or see http://www.sybase.com/detail?id=1015780.
The following diagram depicts the procedure for building an UltraLite embedded SQL application. In addition to your source files, you need a reference database that contains the tables and indexes you wish to use in your application.
To build an UltraLite embedded SQL application
Start the Adaptive Server Anywhere personal database server, specifying your reference database.
Run the SQL preprocessor on each embedded SQL source file.
The SQL preprocessor is the sqlpp command-line utility. It carries out two functions in an UltraLite development project:
It preprocesses the embedded SQL files, producing C files to be compiled into your application.
It adds the SQL statements to the reference database, for use by the UltraLite generator.
Caution sqlpp overwrites the output file without regard to its contents. Ensure that the output file name does not match the name of any of your source files. By default, sqlpp constructs the output file name by changing the suffix of your source file to .c. When in doubt, specify the output file name explicitly, following the name of the source file. |
Use the sqlpp -c
command-line option to connect to the reference database and the -p
command-line option to specify a project name. Use the same project name for each embedded SQL file in your project.
For detailed information about the SQL preprocessor, see The SQL preprocessor.
For information about projects, see Creating an UltraLite project.
Run the UltraLite generator.
The generator analyzes information collected while pre-processing your embedded SQL files. It prepares extra code and writes out a new C source file. This step also relies on your reference database.
Enter the following command at a command-prompt:
ulgen -c "connection-string" options
where options depend on the specifics of your project.
The UltraLite generator command line customizes its behavior. The following command-line switches are particularly important:
-c You must supply a connection string, to connect to the reference database.
For information on Adaptive Server Anywhere connection strings, see Connection parameters.
-f Specify the output file name.
-j Specify the UltraLite project name.
For more information on UltraLite generator options, see The UltraLite generator.
Compile each C or C++ source file for the target platform of your choice. Include
each C files generated by the SQL preprocessor,
the C file made by the UltraLite generator,
any additional C or C++ source files that comprise your application.
Link all these object files, together with the UltraLite runtime library.
Suppose that your project contains two embedded SQL source files, called store.sqc and display.sqc. You could give your project the name salesdb and process these two commands using the following commands. (Each command should be entered on a single line.)
sqlpp -c "uid=dba;pwd=sql" -p salesdb store.sqc sqlpp -c "uid=dba;pwd=sql" -p salesdb display.sqc
These two commands generate the files store.c and display.c, respectively. In addition, they store information in the reference database for the UltraLite analyzer.