MATCH_RECOGNIZE Query Queries

18-14 Oracle Complex Event Processing CQL Language Reference using_clause::= usinglist::= on page 20-6 Consider the query that Example 18–9 shows. Example 18–9 DIFFERENCE USING Clause query id=q0 ISTREAM SELECT c1 FROM S [RANGE 1 NANOSECONDS] DIFFERENCE USING c1 query Table 18–1 shows sample input for this query. The Relation column shows the contents of the relation S [RANGE 1 NANOSECONDS] and the Output column shows the query results after the DIFFERENCE USING clause is applied. This clause allows you to succinctly detect only differences in the IStream output. When you specify the usinglist in the DIFFERENCE USING clause, you may specify columns by: ■ attribute name: use this option when you are selecting by attribute name. Example 18–10 shows attribute name c1 in the DIFFERENCE USING clause usinglist. ■ alias: use this option when you want to include the results of an expression where an alias is specified. Example 18–10 shows alias logval in the DIFFERENCE USING clause usinglist. Table 18–1 DIFFERENCE USING Clause Affect on IStream Input Relation Output 1000: +5 {5} +5 1000: +6 {5, 6} +6 1000: +7 {5, 6, 7} +7 1001: +5 {5, 6, 7, 5} 1001: +6 {5, 6, 7, 5, 6} 1001: +7 {5, 6, 7, 5, 6, 7} 1001: +8 {5, 6, 7, 5, 6, 7, 8} +8 1002: +5 {5, 6, 7, 5, 6, 7, 8, 5} 1003: -5 {5, 6, 7, 5, 6, 7, 8} 1003: -5 {5, 6, 7, 6, 7, 8} 1003: -5 {6, 7, 6, 7, 8} 1003: -6 {6, 7, 7, 8} 1003: -6 {7, 7, 8} 1003: -7 {7, 8} 1003: -7 {8} 1003: -8 {} 1004: +5 {5} +5 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.