beautypg.com

Sql syntax in 5800 system queries, Literals in queries, Dynamic parameters – Sun Microsystems Sun StorageTek 5800 User Manual

Page 118: String literals, Numeric literals

background image

SQL Syntax in 5800 System Queries

General Unicode characters outside of the ASCII range in queries are allowed in only two places
to the 5800 system. Specifically, both attribute names and literal values may contain general
Unicode characters. All text that is not either an attribute name nor a literal value is passed
unchanged to the underlying query engine, and must consist of ASCII characters only. An
attempt to pass non-ASCII characters in a query will result in an error.

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(
"system.test.type_date=?");
stmt.bindParameter(date_value,1);

QueryResultSet qrs = query(stmt);

For further information, see

“query (with PreparedStatement)” on page 35

,

“query (with

PreparedStatement

and selectKeys)” on page 35

and

“PreparedStatement” on page 36

.

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 In Queries

Sun StorageTek 5800 System Client API Reference Manual • June 2008

118