Where Clause Query Building Blocks

18-12 Oracle Complex Event Processing CQL Language Reference group by orderId ]]query For more information, see: ■ Section 1.1.5, Stream-to-Stream Operators ■ xmltable_clause::= on page 20-6 ■ SQLXML SQLX on page 5-16

18.2.7 Function TABLE Query

Use the TABLE clause to access the multiple rows returned by a built-in or user-defined function in the FROM clause of an Oracle CQL query. The TABLE clause converts the set of returned rows into an Oracle CQL relation. Because this is an external relation, you must join the TABLE function clause with a stream. table_clause::= object_expr::= on page 5-19, identifier::= on page 7-16, datatype::= on page 2-2 Note the following: ■ The function must return an array type or Collection type. ■ You must join the TABLE function clause with a stream. Example 18–7 shows a data cartridge TABLE clause that invokes the Oracle Spatial method getContainingGeometries, passing in one parameter InputPoints.point. The return value of this method, a Collection, is aliased as validGeometries. The relation that the TABLE clause returns is aliased as R2. Example 18–7 Data Cartridge TABLE Query query id=q1[CDATA[ RSTREAM SELECT R2.validGeometries.shape as containingGeometry, R1.point as inputPoint FROM InputPoints[now] as R1, TABLE getContainingGeometriesspatial InputPoints.point as validGeometries AS R2 ]]query Example 18–8 shows an invalid data cartridge TABLE query that fails to join the data cartridge TABLE clause with another stream because the function getAllGeometriesspatial was called without any parameters. Oracle CEP invokes the data cartridge method only on the arrival of elements on the joined stream. Example 18–8 Invalid Data Cartridge TABLE Query query id=q2[CDATA[ RSTREAM SELECT R2.validGeometries.shape as containingGeometry FROM Oracle CQL Queries, Views, and Joins 18-13 TABLE getAllGeometriesspatial as validGeometries AS R2 ]]query For more examples, see: ■ Data Cartridge TABLE Query Example: Iterator on page 20-20 ■ Data Cartridge TABLE Query Example: Array on page 20-21 ■ Data Cartridge TABLE Query Example: Collection on page 20-22 For more information, see: ■ table_clause on page 20-10 ■ Section 18.7, Oracle CQL Queries and Oracle Data Cartridges ■ Section 1.1.11, Functions ■ Section 15.1.4.3, Arrays ■ Section 15.1.4.4, Collections

18.2.8 Cache Query

Using an Oracle CQL processor, you can specify a cache as an event source. You can query this event source and join it with other event sources using a Now window only. Oracle CEP cache event sources are pull data sources: that is, Oracle CEP polls the event source on arrival of an event on the data stream. For more information, see Section 18.5, Oracle CQL Queries and the Oracle CEP Server Cache .

18.2.9 Sorting Query Results

Use the ORDER BY clause to order the rows selected by a query. order_by_clause::= order_by_list::= on page 20-5 Sorting by position is useful in the following cases: ■ To order by a lengthy select list expression, you can specify its position in the ORDER BY clause rather than duplicate the entire expression. ■ For compound queries containing set operators UNION, INTERSECT, MINUS, or UNION ALL, the ORDER BY clause must specify positions or aliases rather than explicit expressions. Also, the ORDER BY clause can appear only in the last component query. The ORDER BY clause orders all rows returned by the entire compound query. The mechanism by which Oracle CEP sorts values for the ORDER BY clause is specified by your Java locale.

18.2.10 Detecting Differences in Query Results

Use the DIFFERENCE USING clause to succinctly detect differences in the IStream or DStream of a query.