Contents Index Creating an UltraLite project Writing UltraLite SQL statements pdf/preface.pdf

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

Adding SQL statements to an UltraLite project


Each UltraLite application carries out a set of data access requests. These requests are implemented differently in each development model, but the data access requests are defined in the same way for each model.

You define the data access requests that an UltraLite application can carry out by adding a set of SQL statements to the UltraLite project for that application in your reference database. The UltraLite generator then creates the code for a database engine that can execute the set of SQL statements.

In the C++ API, you can also use SQL Remote publications to define data access methods. For information on using publications, see Defining UltraLite tables.

You can add SQL statements to an UltraLite project using Sybase Central, or by directly calling a system stored procedure. If you are using embedded SQL, the SQL preprocessor adds the SQL statements in your embedded SQL source files to the reference database for you.

To add a SQL statement to an UltraLite project (Sybase Central)

  1. From Sybase Central, connect to your reference database.

    For instructions on using Sybase Central, see Connect to the sample database.

  2. In the left pane, open the database container.

  3. In the left pane, open the UltraLite Projects folder.

  4. Open the project for your application.

  5. Double-click Add UltraLite Statement.

    The UltraLite Statement Creation wizard appears.

  6. Enter a short, descriptive name for the statement, and click Next

  7. Enter the statement itself, and click Finish to add the statement to the project.

    You can test the SQL statements against the database by right-clicking the statement and choosing Execute From Interactive SQL from the popup menu.

    For information on what kinds of statement you can use, see Writing UltraLite SQL statements.

To add a SQL statement to an UltraLite project (SQL)

To add a SQL statement to an UltraLite project (embedded SQL)

Notes 

Statement names should be short and descriptive. They are used by the UltraLite generator to identify the statement for use in Java or in the C++ API. For example, a statement named ProductQuery generates a C++ API class named ProductQuery and a Java constant named PRODUCT_QUERY. Names should be valid SQL identifiers.

The SQL statement syntax is checked when you add the statement to the database, and syntax errors give an error message to help you identify mistakes.

You can use Sybase Central or ul_add_statement to update a statement in a project, in just the same way as you add a statement. If a statement already exists, it is overwritten with the new syntax. You must regenerate the UltraLite code whenever you modify a statement.


Contents Index Creating an UltraLite project Writing UltraLite SQL statements pdf/preface.pdf