UltraLite User's Guide
Developing UltraLite Applications
Defining SQL statements for your application
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)
From Sybase Central, connect to your reference database.
For instructions on using Sybase Central, see Connect to the sample database.
In the left pane, open the database container.
In the left pane, open the UltraLite Projects folder.
Open the project for your application.
Double-click Add UltraLite Statement.
The UltraLite Statement Creation wizard appears.
Enter a short, descriptive name for the statement, and click Next
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)
From Interactive SQL or another application, enter the following command:
call ul_add_statement( 'project-name', 'statement-name', 'SQL-statement' )
where project-name is the name of the project, statement-name is a short descriptive name, and SQL-statement is the actual SQL statement.
For more information, see ul_add_statement system procedure.
To add a SQL statement to an UltraLite project (embedded SQL)
If you are using the embedded SQL development model, specify the UltraLite project name on the SQL Preprocessor command line.
No statement name is used in embedded SQL development.
For more information, see Pre-processing your embedded SQL files.
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.