Run-Time Query Naming Lexical Conventions for Parameter Values

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. 18-22 Oracle Complex Event Processing CQL Language Reference Example 18–18 shows how to create a query q5 that uses a left outer join between streams S0, with schema c1 integer, c2 float, and S1, with schema c1 integer, c2 float. Example 18–18 Outer Joins query id=q5[CDATA[ SELECT a.c1+b.c1 FROM S0[range 5] AS a LEFT OUTER JOIN S1[range 3] AS b ON b.c2 = a.c2 WHERE b.c2 3 ]]query Use the ON clause to specify a join condition. Doing so lets you specify join conditions separate from any search or filter conditions in the WHERE clause. You can perform the following types of outer join: ■ Section 18.4.2.1, Left Outer Join ■ Section 18.4.2.2, Right Outer Join ■ Section 18.4.2.3, Outer Join Look-Back

18.4.2.1 Left Outer Join

To write a query that performs an outer join of streams A and B and returns all stream elements from A a left outer join, use the LEFT OUTER JOIN syntax in the FROM clause as Example 18–19 shows. For all stream elements in A that have no matching stream elements in B, Oracle CEP returns null for any select list expressions containing stream elements of B. Example 18–19 Left Outer Joins query id=q5[CDATA[ SELECT a.c1+b.c1 FROM S0[range 5] AS a LEFT OUTER JOIN S1[range 3] AS b ON b.c2 = a.c2 WHERE b.c2 3 ]]query

18.4.2.2 Right Outer Join

To write a query that performs an outer join of streams A and B and returns all stream elements from B a right outer join, use the RIGHT OUTER JOIN syntax in the FROM clause as Example 18–20 shows. For all stream elements in B that have no matching stream elements in A, Oracle CEP returns null for any select list expressions containing stream elements of A. Example 18–20 Right Outer Joins query id=q5[CDATA[ SELECT a.c1+b.c1 FROM S0[range 5] AS a RIGHT OUTER JOIN S1[range 3] AS b ON b.c2 = a.c2 WHERE b.c2 3 ]]query

18.4.2.3 Outer Join Look-Back

You can create an outer join that refers or looks-back to a previous outer join as Example 18–21 shows.