Although Oracle Commerce Navigation requests can contain just a single AnalyticsQuery object, the AnalyticsQuery object can consist of an arbitrary number of Analytics statements, each of which represents a request to compute a set of Analytics result records.
An Analytics query can consist of any number of statements, each of which might compute related or independent analytics results.
Each Analytics statement in a query must be given a unique name, as these names are later used to retrieve Analytics results from the Navigation object returned by the MDEX Engine.
Example 2. Examples
The following code example creates two Analytics statements and inserts them into a containing AnalyticsQuery object:
AnalyticsQuery analytics = ... Statement s1 = new Statement(); s1.setName("Statement One"); // …populate s1 with analytics operations analytics.add(s1); Statement s2 = new Statement(); s2.setName("Statement Two"); // …populate s2 with analytics operations analytics.add(s2);
The same example using the text-based syntax is:
RETURN "Statement One" AS ... RETURN "Statement Two" AS ...
The names assigned to Analytics statements are used to retrieve results from the Navigation object returned for the containing ENEQuery, as in the following example:
ENEQueryResults results = ... AnalyticsStatementResult s1Results; s1Results = results.getNavigation(). getAnalyticsStatementResult("Statement One");
By default, the result of each statement in an Analytics query is returned to the calling application. But in some cases, an Analytics statement is only intended as input for other Analytics statements in the same query, not for presentation to the end user. In such cases, it is valuable to inform the system that the statement results are not needed, but are only defined as an intermediate step. Using the programmatic API, a Statement method is provided to accomplish this:
s1.setShown(false);
In the text-based syntax, this is accomplished using the DEFINE keyword in place of the RETURN keyword, for example:
DEFINE "Statement One" AS ...
The concept of query layering and inter-query references is described in later sections of this guide. So far, we have discussed statements in the abstract as parts of queries that compute analytics results, but have not described their capabilities or contents.