Object Query Definition Guidelines

Understand how to define object queries.

Support for various compact databases

Since object queries can run on multiple mobile devices that may run different compact databases (UltraLiteJ® or SQLite® for example), object queries support a subset of UltraLiteJ SQL statements.

Object query restrictions
SQL Restrictions
Select statement

Supported – Order by

Unsupported:
  • Bulk and Math functions
  • Group by
  • For
  • Option
  • Row limitation
  • As
Input-parameter

Supported – :name

Comparison operators Supported:
  • Date format is YYYY-MM-DD and contained in single quotes.
  • Literal strings must be contained in single quotes.
From clause Supports multiple MBOs.

See the UltraLiteJ documentation for more information about the UltraLite SELECT statement clauses.

Object queries must use aliases

Define the object query using an alias that references the MBO and attribute names (not table and column names from which they are derived). For example, if you have an MBO named Cust with a cust_id attribute (which is a primary key), defining this object query:
SELECT c.* from Cust c WHERE c.cust_id = :cust_id
and this parameter:
  • Name – cust_id
  • Datatype – INT

results in an object query that returns a single row from the Customer table. You must use an alias (c and c.attribute_name) in the query definition or an error occurs during code generation.

General behavior

General object query behavior, including assigning parameters a default value/primary key includes:

Validation rules

Follow these rules when defining an object query:
  • All columns defined in the MBO must appear in the result set of the object query. If not, an error is generated when running the object query similar to:
    java.sql.SQLException:JZ008: invalid column index value at 2 
  • "findBy" is a reserved word for an object query. If you create an operation starting with "findBy", you receive the warning message: Operation name ''{0}'' starts with 'findby', which may cause name conflict when generating client code.
  • Do not duplicate query or operation names.
  • Do not use these reserved names as the query name: "pull", "downloadData."
  • Do not use an operation name, query name, or attribute name that is the same as the name of the MBO to which they belong.
  • While clicking Generate generates a valid query, Sybase Unwired WorkSpace does not parse or validate the generated query. If you modify the query, be mindful that parameters are not validated until code is generated. For example, this error (mixed case between parameter name and query definition) is not detected until code generation or deployment:

    Parameter: Param1 (INT)

    Query definition: SELECT x.* FROM TravelRequest x WHERE x.trvl_Id = :param1