Relational Database Table Query XMLTable Query

Oracle CQL Queries, Views, and Joins 18-15 ■ position: use this option when you want to include the results of an expression where no alias is specified. Specify position as a constant, positive integer starting at 1, reading from left to right. Example 18–10 specifies the result of expression functc2, c3 by its position 3 in the DIFFERENCE USING clause usinglist. Example 18–10 Specifying the usinglist in a DIFFERENCE USING Clause query id=q1 ISTREAM SELECT c1, logc4 as logval, functc2, c3 FROM S [RANGE 1 NANOSECONDS] DIFFERENCE USING c1, logval, 3 query You can use the DIFFERENCE USING clause with both IStream and DStream operators. For more information, see: ■ using_clause::= on page 20-6 ■ IStream Relation-to-Stream Operator on page 4-24 ■ DStream Relation-to-Stream Operator on page 4-25

18.2.11 Parameterized Queries

You can parameterize an Oracle CQL query and bind parameter values at run time using the :n characater string as a placeholder, where n is a positive integer that corresponds to the position of the replacement value in a params element. Example 18–11 shows a paramaterized Oracle CQL query. Example 18–11 Parameterized Oracle CQL Query n1:config xmlns:n1=http:www.bea.comnswlevsconfigapplication xmlns:xsi=http:www.w3.org2001XMLSchema-instance ... processor namemyProcessorname rules query id=MarketRule[CDATA[ SELECT symbol, AVGprice AS average, :1 AS market FROM StockTick [RANGE 5 SECONDS] WHERE symbol = :2 ]]query rules bindings binding id=MarketRule params id=nasORCLNASDAQ, ORCLparams params id=nyJPMNYSE, JPMparams params id=nyWFCNYSE, WFCparams binding bindings processor processor namesummarizeResultsname Note: You cannot parameterize a view. 18-16 Oracle Complex Event Processing CQL Language Reference rules query id=SummarizeResultsRule[CDATA[ select crossRate1 || crossRate2 as crossRatePair, count as totalCount, :1 as averageInternalPrice from CrossRateStream group by crossRate1,crossRate2 having :2 ]]query rules bindings binding id=SummarizeResultsRule params id=avgcountavginternalPrice, count 0params binding bindings processor n1:config In this example, the: ■ MarketRule query specifies two parameters: the third term in the SELECT and the value of symbol in the WHERE clause ■ SummarizeResultsRule query specifies two parameters: the third term in the SELECT and the value of the HAVING clause. This section describes: ■ Section 18.2.11.1, Parameterized Queries in Oracle CQL Statements ■ Section 18.2.11.2, The bindings Element ■ Section 18.2.11.3, Run-Time Query Naming ■ Section 18.2.11.4, Lexical Conventions for Parameter Values ■ Section 18.2.11.5, Parameterized Queries at Runtime ■ Section 18.2.11.6, Replacing Parameters Programmatically

18.2.11.1 Parameterized Queries in Oracle CQL Statements

You may specify a placeholder anywhere an arithmetic expresion or a String literal is legal in an Oracle CQL statement. For example: ■ SELECT list items ■ WHERE clause predicates ■ WINDOW constructs such as RANGE, SLIDE, ROWS, and PARTITION BY ■ PATTERN duration clause For more information, see: ■ arith_expr on page 5-6 ■ Literals on page 2-8

18.2.11.2 The bindings Element

Parameter values are contained by a bindings element. There may be one bindings element per processor element. For each parameterized query, the bindings element must contain a binding element with the same id as the query.