UltraLite Embedded SQL User's Guide
Introduction to Embedded SQL
When developing embedded SQL applications, you mix SQL statements in with standard C or C++ source code. In order to develop embedded SQL applications you should be familiar with the C or C++ programming language.
The development process for embedded SQL applications is as follows:
Design your database.
Prepare an Adaptive Server Anywhere reference database that contains the tables and indexes you wish to include in your UltraLite database.
Write your source code in an embedded SQL source file, which typically has extension .sqc.
When you need data access in your source code, use the SQL statement you wish to execute, prefixed by the EXEC SQL keywords. For example:
EXEC SQL SELECT price, prod_name INTO :cost, :pname FROM ULProduct WHERE prod_id= :pid; if((SQLCODE==SQLE_NOTFOUND)||(SQLCODE<0)) { return(-1); }
Preprocess the .sqc files.
SQL Anywhere Studio includes a SQL preprocessor (sqlpp), which reads the .sqc files, accesses an Adaptive Server Anywhere reference database, and generates .c or .cpp files. These files hold function calls to the UltraLite runtime library.
Compile your .c or .cpp files.
You can compile the generated .c or .cpp files just as you compile other .c or .cpp files.
Link the .c or .cpp files.
You must link the files against the UltraLite runtime library.
For a full description of the embedded SQL development process, see Building Embedded SQL Applications.