Chapter 7 Working With the Query Language : Querying the Cache and Using Query Results

Querying the Cache and Using Query Results
To use the query language features, you put query text (SQL-like statements that retrieve information from the cache) as arguments to an appropriate function from the CEP Query function catalog and place the query functions in one or more rule functions.
You can also use bind variables to create prepared statements.
Query Function Catalog
A catalog of functions called CEP Query is provided for use in writing and managing queries. The following categories and functions are provided in the catalog:
Query category: create(), delete(), exists()
Callback category: delete(), exists(), getStatementName()
ResultSet category: close(), get(), isBatchEnd(), isOpen(), next()
Statement category: clearSnapshotRequired(), clearVars(), close(), execute(), executeWithCallback(), getSnapshotRequired(), getVar(), isOpen(), open(), setSnapshotRequired(), setVar()
Each category also has a Metadata subcategory, which contains functions such as findColumn(), getColumnCount(), getColumnName(), getColumnType(), getQueryName(), and getStatementName().
Tooltips associated with all these functions show the function signatures and other helpful text. The tooltips are available in TIBCO Designer and in the online reference, TIBCO BusinessEvents Functions Reference.
For general information on using the functions provided with BusinessEvents, see Understanding and Working With Functions in TIBCO BusinessEvents User’s Guide.
Using Functions Within Queries
Many of the available catalog functions as well as custom functions can be used in the text of a query. You can also use rule functions from the same project.
Functions that can’t be used in queries
The following functions cannot be used within queries:
Rule functions with a Validity field that is set to anything other than "Action, Condition, Query." (The Validity field is in the rule function Configuration tab.)
For information on custom functions see Chapter 4, Creating Custom Functions.
Using Bind Variables
You can place bind variables in the query text argument of the query definition. The values of the variables can be set when a query statement is opened, enabling a single query definition to be reused.
See Using Bind Variables in Query Text for details.
Limitation in Use of Arrays
You can use arrays within expressions in a query, but returning arrays in the results of the query is not supported in this release.