Summary of Functions Used to Create and Execute Queries
All queries are created and executed using a set of query functions. The query functions are called from rule functions in the query agent.
Three functions are mandatory, and additional functions are available for different purposes.
Create the Query
First a Query.create()
function creates the query definition which contains the query text and a name for the definition.
Create the Query Statement
Then the Query.Statement.open()
function is used to create a query statement, which is a named instance of the query definition.
Execute an Instance of the Query Statement and Obtain Results
Choose one of these ways to execute a query instance:
- For snapshot queries, you can use either the
Query.Statement.execute()
function or aQuery.Statement.executeWithCallback()
function. - For continuous queries you must use the
Query.Statement.executeWithCallback()
function orQuery.Statement.executeWithBatchCallback()
function, with theIsContinuous
parameter set to true.These functions are generally placed in an event preprocessor rule function.
Use Results
To use results returned by a query, you can create events to send information between query and inference agents. You could also send results out to some other system. The use to which results are put depends on the business need.
See The Query Language Usage for more details.