Sun StorageTek 5800 System Client API Reference Manual

Literals In Queries

This section details the kinds of literals that can occur in 5800 system queries.

Dynamic Parameters

5800 system queries allow dynamic parameters. A dynamic parameter is indicated by the presence of a question mark in the query string (for example, the query name=? AND address=?). The bindParameter call is used in Java to bind typed values for use in place of the question marks.

For the Java API, the syntax is:

     import com.sun.honeycomb.client.PreparedStatement;
     import com.sun.honeycomb.client.QueryResultSet;
     Date date_value= new Date();
     PreparedStatement stmt = new PreparedStatement(
     QueryResultSet qrs = query(stmt);

For further information, see query (with PreparedStatement), query (with PreparedStatement and selectKeys) and PreparedStatement.

String Literals

String literals are surrounded by single quotes (for example, 'The Lighter Side’). You can embed single quote characters in a query by doubling them (for example, ’Susan’’s House’). Any UTF-8 string can be included in a string literal (except the null character, which is treated as a string terminator by the C API).

Numeric Literals

Only ASCII digits are recognized as numeric literals. For example, 45, -1, 3.14, 5.2E10. Digits from other parts of the Unicode code space will cause a parse error.

Literals for 5800 System Data Types

For each 5800 system data type, there is a syntax to include literals of that type in a query string. The syntax is {type_name ’stringliteral’}. For example, consider the query:

timestamp_field<{timestamp ’2006-10-26T12:00:00Z’}

In particular, this syntax can be used to query for a particular object ID:

system.object_id = {objectid ’0200011e61c159bdfa654e11db8a45cafecafecafe000000000200000000’}

For comparing against binary values, either of the following forms may be used:

binary_field = x’beeffeed’

binary_field = {binary ’beeffeed’}

For more information, see Canonical String Format.