Contents Index Adding SQL statements to an UltraLite project Adding user authentication to your application pdf/preface.pdf

UltraLite User's Guide
  Developing UltraLite Applications
    Defining SQL statements for your application

Writing UltraLite SQL statements


This section describes what SQL statements you can add to an UltraLite project, and describes how to use placeholders in your SQL statements.

For information on the range of SQL that you can use, see SQL features and limitations of UltraLite applications.

How to supply double quotes 

The SQL statement that you enter, whether into Sybase Central or as an argument to ul_add_statement, is added to the reference database as a string. It must therefore conform to the rules for SQL strings.

You must escape some characters in your SQL statements using the backslash character.

For information on SQL strings, see Strings.

Using variables with statements 

For most insert or update statements, you do not know the new values ahead of time. You can use question marks as placeholders for variables, and supply values at run time:

call ul_add_statement(
   'ProductApp',
   'AddCap',
   'INSERT INTO \"DBA\".product ( id, name, price )
      VALUES( ?, ?, ? )'
)

Placeholders can also be used in the WHERE clause of queries:

call ul_add_statement(
   'ProductApp',
   'ProductQuery',
   'SELECT id, name, price
    FROM \"DBA\".product
    WHERE price > ?'
)

The backslash characters are used to escape the double quotes.

In embedded SQL, you use host variables as placeholders. For more information, see Using host variables.

For SQL statements containing placeholders, an extra parameter on the Open or Execute method of the generated C++ class is defined for each parameter. For Java applications, you use the JDBC set methods to assign values for the parameters.


Contents Index Adding SQL statements to an UltraLite project Adding user authentication to your application pdf/preface.pdf