Functions Over Correlation Variables in the DEFINE Clause Referencing Attributes in the DEFINE Clause

Pattern Recognition With MATCH_RECOGNIZE 19-19 produces the same result as: ALL MATCHES PATTERN A? B Without the ALL MATCHES clause, overlapping matches are not returned, and quantifiers such as the asterisk determine which among a set of candidate and overlapping matches is the preferred one for output. The rest of the overlapping matches are discarded. pattern_skip_match_clause::= Consider the query tkpattern_q41 in Example 19–18 that uses ALL MATCHES and the data stream tkpattern_S11 in Example 19–19 . Stream tkpattern_S11 has schema c1 integer, c2 integer. The query returns the stream in Example 19–20 . The query tkpattern_q41 in Example 19–18 will report a match when the input stream values, when plotted, form the shape of the English letter W. The relation in Example 19–20 shows an example of overlapping instances of this W-pattern match. There are two types of overlapping pattern instances: ■ Total: Example of total overlapping: Rows from time 3000-9000 and 4000-9000 in the input, both match the given pattern expression. Here the longest one 3000-9000 will be preferred if ALL MATCHES clause is not present. ■ Partial: Example of Partial overlapping: Rows from time 12000-21000 and 16000-23000 in the input, both match the given pattern expression. Here the one which appears earlier is preferred when ALL MATCHES clause is not present. This is because when ALL MATCHES clause is omitted, we start looking for the next instance of pattern match at a tuple which is next to the last tuple in the previous matched instance of the pattern. Example 19–18 ALL MATCHES Clause Query query id=tkpattern_q41[CDATA[ select T.firstW, T.lastZ from tkpattern_S11 MATCH_RECOGNIZE MEASURES A.c1 as firstW, lastZ.c1 as lastZ ALL MATCHES PATTERNA W+ X+ Y+ Z+ DEFINE W as W.c2 prevW.c2, X as X.c2 prevX.c2, Y as Y.c2 prevY.c2, Z as Z.c2 prevZ.c2 as T ]]query Example 19–19 ALL MATCHES Clause Stream Input Timestamp Tuple 1000 1,8 2000 2,8 3000 3,8 19-20 Oracle Complex Event Processing CQL Language Reference 4000 4,6 5000 5,3 6000 6,7 7000 7,6 8000 8,2 9000 9,6 10000 10,2 11000 11,9 12000 12,9 13000 13,8 14000 14,5 15000 15,0 16000 16,9 17000 17,2 18000 18,0 19000 19,2 20000 20,3 21000 21,8 22000 22,5 23000 23,9 24000 24,9 25000 25,4 26000 26,7 27000 27,2 28000 28,8 29000 29,0 30000 30,4 31000 31,4 32000 32,7 33000 33,8 34000 34,6 35000 35,4 36000 36,5 37000 37,1 38000 38,7 39000 39,5 40000 40,8 41000 41,6 42000 42,6 43000 43,0 44000 44,6 45000 45,8 46000 46,4 47000 47,3 48000 48,8 49000 49,2 50000 50,5 51000 51,3 52000 52,3 53000 53,9 54000 54,8 55000 55,5 56000 56,5 57000 57,9 58000 58,7 59000 59,3 60000 60,3 Example 19–20 ALL MATCHES Clause Stream Output Timestamp Tuple Kind Tuple 9000: + 3,9 9000: + 4,9 11000: + 6,11 11000: + 7,11 19000: + 12,19