This topic explains how to build a query string in VMware Tanzu GemFire.

A query string is a fully-formed Object Query Language (OQL) statement that can be passed to a query engine and executed against a data set. The OQL statement must be a SELECT expression that references at least one region.

To build a query string, combine supported keywords, expressions, and operators to create an expression that returns the information that you require.

A query string follows the rules specified by the query language and grammar. It can include:

  • Namescopes: For example, the IMPORT statement. See IMPORT Statement.
  • Path Expressions: For example, in the query SELECT * FROM /exampleRegion,/exampleRegion is a path expression. See FROM Clause.
  • Attribute Names: For example, in the query SELECT DISTINCT * FROM /exampleRegion p WHERE p.position1.secId = '1', we access the secId attribute of the Position object. See WHERE Clause.
  • Method Invocations: For example, in the query SELECT DISTINCT * FROM /exampleRegion p WHERE p.name.startsWith('Bo'), we invoke the startsWith method on the Name object. See WHERE Clause.
  • Operators: Comparison operators (=,<,>,<>), unary operators (NOT), logical operators (AND, OR), and others. See Operators for a complete list.
  • Literals: Boolean, date, time, and others. See Supported Literals for a complete list.
  • Query Bind Parameters: For example, in the query SELECT DISTINCT * FROM $1 p WHERE p.status = $2, $1 and $2 are parameters that can be passed to the query during runtime. See Using Query Bind Parameters for more details.
  • Preset Query Functions: For example, ELEMENT(expr) and IS_DEFINED(expr). See SELECT Statement for other available functions.
  • SELECT Statements: For example, in the example queries above SELECT * or SELECT DISTINCT *. See SELECT Statement for other available functions.
  • Comments: OQL permits extra characters to accompany the query string without changing the string’s definition. Form a multi-line comment by enclosing the comment body within /* and */ delimiters. OQL does not permit nested comments. A single line comment body consists of all of the characters to the right of -- (two hyphens) on a single line.

The components listed above can all be part of the query string, but none of the components are required. At a minimum, a query string contains an expression that can be evaluated against specified data.

The following sections provide guidelines for the query language building blocks that are used when writing typical Tanzu GemFire queries.

check-circle-line exclamation-circle-line close-line
Scroll to top icon