Schema Object Naming Guidelines Schema Object Naming Examples

3 Pseudocolumns 3-1 3 Pseudocolumns A pseudocolumn behaves like a stream element, but is not actually part of the tuple.

3.1 Introduction to Pseudocolumns

You can select from pseudocolumns, but you cannot modify their values. A pseudocolumn is also similar to a function without arguments see Section 1.1.11, Functions . Oracle CQL supports the following pseudocolumns: ■ Section 3.2, ELEMENT_TIME Pseudocolumn

3.2 ELEMENT_TIME Pseudocolumn

Every stream element of a base stream or dervied stream a view that evaluates to a stream has an associated element time.The ELEMENT_TIME pseudo column returns this time as an Oracle CQL native type bigint. This section describes: ■ Section 3.2.1, Understanding the Value of the ELEMENT_TIME Pseudocolumn ■ Section 3.2.2, Using the ELEMENT_TIME Pseudocolumn in Oracle CQL Queries For more information, see: ■ pseudo_column::= on page 7-4 ■ to_timestamp on page 8-20

3.2.1 Understanding the Value of the ELEMENT_TIME Pseudocolumn

The value of the ELEMENT_TIME pseudocolumn depends on whether or not you configure the stream element’s channel as system- or application-timestamped.

3.2.1.1 ELEMENT_TIME for a System-Timestamped Stream

In this case, the element time for a stream element is assigned by the Oracle CEP system in such a way that subtracting two values of system-assigned time will give a duration that roughly matches the elapsed wall clock time. Note: ELEMENT_TIME is not supported on members of an Oracle CQL relation. For more information, see Section 1.1.1, Streams and Relations . 3-2 Oracle Complex Event Processing CQL Language Reference For more information, see System-Timestamped Channels in the Oracle Complex Event Processing Developers Guide for Eclipse.

3.2.1.2 ELEMENT_TIME for an Application-Timestamped Stream

In this case, the associated element time is assigned by the application using the application assembly file wlevs:expression element to specify a derived timestamp expression. Oracle CEP processes the result of this expression as follows: ■ Section 3.2.1.2.1, Dervied Timestamp Expression Evalutes to int or bigint ■ Section 3.2.1.2.2, Dervied Timestamp Expression Evalutes to timestamp For more information, see Application-Timestamped Channels in the Oracle Complex Event Processing Developers Guide for Eclipse.

3.2.1.2.1 Dervied Timestamp Expression Evalutes to int or bigint If the dervied timestamp

expression evaluates to an Oracle CQL native type of int, then it is cast to and returned as a corresponding bigint value. If the expression evaluates to an Oracle CQL native type of bigint, that value is returned as is.

3.2.1.2.2 Dervied Timestamp Expression Evalutes to timestamp If the derived timestamp

expression evaluates to an Oracle CQL native type of timestamp, it is converted to a long value by expressing this time value as the number of milliseconds since the standard base time known as the epoch, namely January 1, 1970, 00:00:00 GMT.

3.2.2 Using the ELEMENT_TIME Pseudocolumn in Oracle CQL Queries

This section describes how to use ELEMENT_TIME in various queries, including: ■ Section 3.2.2.1, Using ELEMENT_TIME With SELECT ■ Section 3.2.2.2, Using ELEMENT_TIME With GROUP BY ■ Section 3.2.2.3, Using ELEMENT_TIME With PATTERN

3.2.2.1 Using ELEMENT_TIME With SELECT

Example 3–1 shows how you can use the ELEMENT_TIME pseudocolumn in a select statement. Stream S1 has schema c1 integer. Given the input stream that Example 3–2 shows, this query returns the results that Example 3–3 shows. Note that the function to_timestamp is used to convert the Long values to timestamp values. Example 3–1 ELEMENT_TIME Pseudocolumn in a Select Statement query id=q4[CDATA[ select c1, to_timestampelement_time from S1[range 10000000 nanoseconds slide 10000000 nanoseconds] ]]query Example 3–2 Input Stream Timestamp Tuple 8000 80 9000 90 13000 130 15000 150