The bindings Element Parameterized Queries

18-20 Oracle Complex Event Processing CQL Language Reference correlationId, 1 as priority from MAXBIDMINASK as bba, filteredStream[rows 1] as p where bba.cusip = p.cusip ]]query Using this technique, you can achieve the same results as in the subquery case. However, using views you can better control the complexity of queries and reuse views by name in other queries.

18.3.1 Views and Joins

If you create a join between two or more views that have some stream element names in common, then you must qualify stream element names with names of streams. Example 18–14 shows how to use view names to distinguish between the seq stream element in the BIDMAX view and the seq stream element in the ASKMIN view. Example 18–14 Using View Names to Distinguish Between Stream Elements of the Same Name view id=MAXBIDMINASK schema=cusip bidseq bidSrcId bid askseq askSrcId ask bidQty askQty[CDATA[ select bid.cusip, bid.seq, bid.srcId as bidSrcId, bid.bid, ask.seq, ask.srcId as askSrcId, ask.ask, bid.bidQty, ask.askQty from BIDMAX as bid, ASKMIN as ask where bid.cusip = ask.cusip ]]view Otherwise, fully qualified stream element names are optional. However, it is a best practice to always qualify stream element references explicitly. Oracle CEP often does less work with fully qualified stream element names. For more information, see Section 18.4, Joins .

18.3.2 Views and Schemas

You may define the optional schema of the view using a space delimited list of event attribute names as Example 18–15 shows. Example 18–15 Schema With Event Attribute Names Only view id=MAXBIDMINASK schema=cusip bidseq[CDATA[ select ... ]]view

18.4 Joins

A join is a query that combines rows from two or more streams, views, or relations. Oracle CEP performs a join whenever multiple streams appear in the FROM clause of the query. The select list of the query can select any stream elements from any of these streams. If any two of these streams have a stream element name in common, then you must qualify all references to these stream elements throughout the query with stream names to avoid ambiguity. If you create a join between two or more streams, view, or relations that have some stream element names in common, then you must qualify stream element names with the name of their stream, view, or relation. Example 18–16 shows how to use stream names to distinguish between the customerID stream element in the OrderStream stream and the customerID stream element in the CustomerStream stream. Oracle CQL Queries, Views, and Joins 18-21 Example 18–16 Fully Qualified Stream Element Names query id=q0[CDATA[ select from OrderStream[range 5] as orders, CustomerStream[range 3] as customers where orders.customerID = customers.customerID ]]query Otherwise, fully qualified stream element names are optional. However, Oracle recommends that you always qualify stream element references explicitly. Oracle CEP often does less work with fully qualified stream element names. Oracle CEP supports the following types of joins: ■ Inner Joins ■ Outer Joins

18.4.1 Inner Joins

By default, Oracle CEP performs an inner join sometimes called a simple join: a join of two or more streams that returns only those stream elements that satisfy the join condition. Example 18–17 shows how to create a query q4 that uses an inner join between streams S0, with schema c1 integer, c2 float, and S1, with schema c1 integer, c2 float. Example 18–17 Inner Joins query id=q4[CDATA[ select from S0[range 5] as a, S1[range 3] as b where a.c1+a.c2+4.9 = b.c1 + 10 ]]query

18.4.2 Outer Joins

An outer join extends the result of a simple join. An outer join returns all rows that satisfy the join condition and also returns some or all of those rows from one table for which no rows from the other satisfy the join condition. You specify an outer join in the FROM clause of a query using LEFT or RIGHT OUTER JOIN ... ON syntax. from_clause::= non_mt_relation_list::= on page 20-4, relation_variable::= on page 20-4, non_mt_cond_ list::= on page 7-24 Note: When joining against a cache, you must observe additional query restrictions as Section 18.5.1, Creating Joins Against the Cache describes.