Skip Headers
Oracle® CEP CQL Language Reference
11g Release 1 (11.1.1)
E12048-02
  Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
 
Next
Next
 

1 Introduction to Oracle CQL

Oracle Continuous Query Language (Oracle CQL) is a query language based on SQL with added constructs that support streaming data. Using Oracle CQL, you can express queries on data streams to perform complex event processing (CEP) using Oracle CEP.

Oracle CEP (formally known as the WebLogic Event Server) is a Java server for the development of high-performance event driven applications. It is a lightweight Java application container based on Equinox OSGi, with shared services, including the Oracle CEP Service Engine, which provides a rich, declarative environment based on Oracle CQL to improve the efficiency and effectiveness of managing business operations. Oracle CEP supports ultra-high throughput and microsecond latency using JRockit Real Time and provides Oracle CEP Visualizer and Oracle CEP IDE for Eclipse developer tooling for a complete real time end-to-end Java Event-Driven Architecture (EDA) development platform.

1.1 Fundamentals of Oracle CQL

Databases are best equipped to run queries over finite stored data sets. However, many modern applications require long-running queries over continuous unbounded sets of data. By design, a stored data set is appropriate when significant portions of the data are queried repeatedly and updates are relatively infrequent. In contrast, data streams represent data that is changing constantly, often exclusively through insertions of new elements. It is either unnecessary or impractical to operate on large portions of the data multiple times.

Many types of applications generate data streams as opposed to data sets, including sensor data applications, financial tickers, network performance measuring tools, network monitoring and traffic management applications, and clickstream analysis tools. Managing and processing data for these types of applications involves building data management and querying capabilities with a strong temporal focus.

To address this requirement, Oracle introduces Oracle CEP, a data management infrastructure that supports the notion of streams of structured data records together with stored relations.

To provide a uniform declarative framework, Oracle offers Oracle Continuous Query Language (Oracle CQL), a query language based on SQL with added constructs that support streaming data.

Oracle CQL is designed to be:

Figure 1-1 shows a simplified view of the Oracle CEP architecture. Oracle CEP server provides the light-weight Spring container for Oracle CEP applications. The Oracle CEP application shown is composed of an event adapter that provides event data to an input channel. The input channel is connected to an Oracle CQL processor associated with one or more Oracle CQL queries that operate on the events offered by the input channel. The Oracle CQL processor is connected to an output channel to which query results are written. The output channel is connected to an event Bean: a user-written Plain Old Java Object (POJO) that takes action based on the events it receives from the output channel.

Figure 1-1 Oracle CEP Architecture

Description of Figure 1-1 follows
Description of "Figure 1-1 Oracle CEP Architecture"

Using Oracle CEP, you can define event adapters for a variety of data sources including JMS, relational database tables, and files in the local filesystem. You can connect multiple input channels to an Oracle CQL processor and you can connect an Oracle CQL processor to multiple output channels. You can connect an output channel to another Oracle CQL processor, to an adapter, to a cache, or an event Bean.

Using Oracle CEP IDE for Eclipse and Oracle CEP Visualizer, you:

Consider the typical Oracle CQL statements that Example 1-1 shows.

Example 1-1 Typical Oracle CQL Statements

<?xml version="1.0" encoding="UTF-8"?>
<n1:config xsi:schemaLocation="http://www.bea.com/ns/wlevs/config/application wlevs_application_config.xsd" 
xmlns:n1="http://www.bea.com/ns/wlevs/config/application" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<processor>
    <name>cqlProcessor</name>
    <rules>
        <view id="lastEvents" schema="cusip bid srcId bidQty ask askQty seq"><![CDATA[ 
            select cusip, bid, srcId, bidQty, ask, askQty, seq 
            from inputChannel[partition by srcId, cusip rows 1]
        ]]></view>
        <view id="bidask" schema="cusip bid ask"><![CDATA[ 
            select cusip, max(bid), min(ask) 
            from lastEvents
            group by cusip
        ]]></view>
            <view ...><![CDATA[
                ...
        ]]></view>
        ...
        <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>
        <query id="BBAQuery"><![CDATA[ 
            ISTREAM(select bba.cusip, bba.bidseq, bba.bidSrcId, bba.bid, bba.askseq, bba.askSrcId, bba.ask, bba.bidQty, bba.askQty, "BBAStrategy" as intermediateStrategy, p.seq as correlationId, 1 as priority 
            from MAXBIDMINASK as bba, inputChannel[rows 1] as p where bba.cusip = p.cusip)
        ]]></query>
    </rules>
</processor>

This example defines multiples views (the Oracle CQL-equivalent of subqueries) to create multiple relations, each building on previous views. Views always act on an inbound channel such as inputChannel. The first view, named lastEvents, selects directly from inputChannel. Subsequent views may select from inputChannel directly or select from previously defined views. The results returned by a view's select statement remain in the view's relation: they are not forwarded to any outbound channel. That is the responsibility of a query. This example defines query BBAQuery that selects from both the inputChannel directly and from previously defined views. The results returned from a query's select clause are forwarded to the outbound channel associated with it: in this example, to outputChannel. The BBAQuery uses a tuple-based stream-to-relation operator (or sliding window).

For more information on these elements, see:

For more information on Oracle CEP server and tools, see:

1.1.1 Streams and Relations

This section introduces the two fundamental Oracle CEP objects that you manipulate using Oracle CQL:

Using Oracle CQL, you can perform the following operations with streams and relations:

1.1.1.1 Streams

A stream is the principle source of data that Oracle CQL queries act on.

Stream S is a bag multi-set of elements (s,T) where s is in the schema of S and T is in the time domain.

Stream elements are tuple-timestamp pairs, which can be represented as a sequence of timestamped tuple insertions. In other words, a stream is a sequence of timestamped tuples. There could be more than one tuple with the same timestamp. The tuples of an input stream are required to arrive at the system in the order of increasing timestamps. For more information, see Section 1.1.10, "Time".

A stream has an associated schema consisting of a set of named attributes, and all tuples of the stream conform to the schema.

The term "tuple of a stream" denotes the ordered list of data portion of a stream element, excluding timestamp data (the s of <s,t>). Example 1-2 shows how a stock ticker data stream might appear, where each stream element is made up of <timestamp value>, <stock symbol>, and <stock price>:

Example 1-2 Stock Ticker Data Stream

...
<timestampN>    NVDA,4
<timestampN+1>  ORCL,62
<timestampN+2>  PCAR,38
<timestampN+3>  SPOT,53
<timestampN+4>  PDCO,44
<timestampN+5>  PTEN,50
...

In the stream element <timestampN+1>  ORCL,62, the tuple is ORCL,62.

By definition, a stream is unbounded.

Oracle CEP represents a stream as a channel as Figure 1-2 shows. Using Oracle CEP IDE for Eclipse, you connect the stream event source (PriceAdapter) to a channel (priceStream) and the channel to an Oracle CQL processor (filterFanoutProcessor) to supply the processor with events. You connect the Oracle CQL processor to a channel (filteredStream) to output Oracle CQL query results to down-stream components (not shown in Figure 1-2).

Figure 1-2 Stream in the Event Processing Network

Description of Figure 1-2 follows
Description of "Figure 1-2 Stream in the Event Processing Network"


Note:

In Oracle CEP, you must use a channel to connect an event source to an Oracle CQL processor and to connect an Oracle CQL processor to an event sink. A channel is optional with other Oracle CEP processor types.

The event source you connect to a stream determines the stream's schema. In Figure 1-2, the PriceAdapter adapter determines the priceStream stream's schema. Example 1-3 shows the PriceAdapter assembly source: the eventTypeName property specifies event type PriceEvent. The event-type-repository defines the property names and types for this event.

Example 1-3 Stream Schema Definition

<wlevs:event-type-repository>
    <wlevs:event-type type-name="PriceEvent">
        <wlevs:properties>
            <wlevs:property name="cusip" type="java.lang.String" />
            <wlevs:property name="bid" type="java.lang.Double" />
            <wlevs:property name="srcId" type="java.lang.String" />
            <wlevs:property name="bidQty" type="java.lang.Integer" />
            <wlevs:property name="ask" type="java.lang.Double" />
            <wlevs:property name="askQty" type="java.lang.Integer" />
            <wlevs:property name="seq" type="java.lang.Long" />
            <wlevs:property name="sector" type="java.lang.String" />
        </wlevs:properties>
    </wlevs:event-type>
</wlevs:event-type-repository>

<wlevs:adapter advertise="true" id="PriceAdapter"
<wlevs:instance-property name="port" value="9008" />
    <wlevs:instance-property name="eventTypeName"
        value="PriceEvent" />
    <wlevs:instance-property name="eventPropertyNames"
        value="srcId,sector,cusip,bid,ask,bidQty,askQty,seq" />
</wlevs:adapter>

Once the event source, channel, and processor are connected as Figure 1-2 shows, you can write Oracle CQL statements that make use of the stream as Example 1-4 shows.

Example 1-4 filterFanoutProcessor Oracle CQL Query Using priceStream

<processor>
    <name>filterFanoutProcessor</name>
    <rules>
        <query id="Yr3Sector"><![CDATA[ 
            select cusip, bid, srcId, bidQty, ask, askQty, seq 
            from priceStream where sector="3_YEAR"
        ]]></query>
        <query id="Yr2Sector"><![CDATA[ 
            select cusip, bid, srcId, bidQty, ask, askQty, seq 
            from priceStream where sector="2_YEAR"
        ]]></query>
        <query id="Yr1Sector"><![CDATA[ 
            select cusip, bid, srcId, bidQty, ask, askQty, seq 
            from priceStream where sector="1_YEAR"
        ]]></query>
    </rules>
</processor>

If you specify more than one query for a processor as Example 1-4 shows, then all query results are output to the processor's out-bound channel (filteredStream in Figure 1-2). Optionally, in the component configuration source, you can use the channel element selector attribute to control which query's results are output as Example 1-5 shows. In this example, query results for query Yr3Sector and Yr2Sector are output to filteredStream but not query results for query Yr1Sector. For more information, see "Channel Component Configuration" in the Oracle CEP IDE Developer's Guide for Eclipse.

Example 1-5 Using selector to Control Which Query Results are Output

<channel>
    <name>filteredStream</name>
    <selector>Yr3Sector Yr2Sector</selector>
</channel>

For more information, see:

1.1.1.2 Relations

Time varying relation R is a mapping from the time domain to an unbounded bag of tuples to the schema of R.

A relation is an unordered, time-varying bag of tuples: in other words, an instantaneous relation. At every instant of time, a relation is a bounded set. It can also be represented as a sequence of timestamped tuples that includes insertions, deletions, and updates to capture the changing state of the relation.

Like streams, relations have a fixed schema to which all tuples conform.

Oracle CEP supports both base and derived streams and relations. The external sources supply data to the base streams and relations.

A base (explicit) stream is a source data stream that arrives at an Oracle CEP adapter so that time is non-decreasing. That is, there could be events that carry same value of time.

A derived (implicit) stream/relation is an intermediate stream/relation that query operators produce. Note that these intermediate operators can be named (through views) and can therefore be specified in further queries.

A base relation is an input relation.

A derived relation is an intermediate relation that query operators produce. Note that these intermediate operators can be named (through views) and can therefore be specified in further queries.

In Oracle CEP, you do not create base relations yourself. The Oracle CEP server creates base relations for you as required.

When we say that a relation is a time-varying bag of tuples, time refers to an instant in the time domain. Input relations are presented to the system as a sequence of timestamped updates which capture how the relation changes over time. An update is either a tuple insertion or deletion. The updates are required to arrive at the system in the order of increasing timestamps. For more information, see Section 1.1.10, "Time".

1.1.1.3 Relations and Oracle CEP Tuple Kind Indicator

By default, Oracle CEP includes time stamp and an Oracle CEP tuple kind indicator in the relations it generates as Example 1-6 shows.

Example 1-6 Oracle CEP Tuple Kind Indicator in Relation Output

Timestamp   Tuple Kind  Tuple
 1000:      +           ,abc,abc
 2000:      +           hihi,abchi,hiabc
 6000:      -           ,abc,abc
 7000:      -           hihi,abchi,hiabc
 8000:      +           hi1hi1,abchi1,hi1abc
 9000:      +           ,abc,abc
13000:      -           hi1hi1,abchi1,hi1abc
14000:      -           ,abc,abc
15000:      +           xyzxyz,abcxyz,xyzabc
20000:      -           xyzxyz,abcxyz,xyzabc

The Oracle CEP tuple kind indicators are:

  • + for inserted tuple

  • - for deleted tuple

  • U for updated tuple indicated when invoking com.bea.wlevs.ede.api.RealtionSink method onUpdateEvent (for more information, see Oracle CEP Java API Reference).

To configure silent operation, see attribute is-silent-relation in "wlevs:channel" in the Oracle CEP IDE Developer's Guide for Eclipse.

In this guide, relations are always shown as not silent: that is, timestamp and Oracle CEP tuple kind indicator are always shown as Example 1-6 shows.

1.1.2 Relation-to-Relation Operators

The relation-to-relation operators in Oracle CQL are derived from traditional relational queries expressed in SQL.

Anywhere a traditional relation is referenced in a SQL query, a relation can be referenced in Oracle CQL.

Consider the following examples for a stream CarSegStr with schema: car_id integer, speed integer, exp_way integer, lane integer, dir integer, and seg integer.

In Example 1-7, at any time instant, the output relation of this query contains the set of vehicles having transmitted a position-speed measurement within the last 30 seconds.

Example 1-7 Relation-to-Relation Operation

<processor>
    <name>cqlProcessor</name>
    <rules>
        <view id="CurCarSeg" schema="car_id exp_way lane dir seg"><![CDATA[ 
            select distinct
                car_id, exp_way, lane, dir, seg 
            from 
                CarSegStr [range 30 seconds]
        ]]></query>
    </rules>
</processor>

The distinct operator is the relation-to-relation operator. Using distinct, Oracle CEP returns only one copy of each set of duplicate tuples selected. Duplicate tuples are those with matching values for each expression in the select list. You can use distinct in a select_clause and with aggregate functions.

For more information on distinct, see:

1.1.3 Stream-to-Relation Operators (Windows)

Oracle CQL supports stream-to-relation operations based on a sliding window. In general, S[W] is a relation. At time T the relation contains all tuples in window W applied to stream S up to T.

window_type::=

Surrounding text describes window_type.gif.

Oracle CQL supports the following built-in window types:

  • range: time-based

    S[Range T], or, optionally,

    S[Range T1 Slide T2]

  • range: time-based unbounded

    S[Range Unbounded]

  • range: time-based now

    S[Now]

  • range: constant value

    S[Range C on ID]

  • tuple-based:

    S[Rows N], or, optionally,

    S[Rows N1 Slide N2]

  • partitioned:

    S[Partition By A1 ... Ak Rows N] or, optionally,

    S[Partition By A1 ... Ak Rows N Range T], or

    S[Partition By A1 ... Ak Rows N Range T1 Slide T2]

The keywords Range and Rows specify how much data you want to query: Range specifies as many tuples as arrive in a given time period; Rows specifies a number of tuples. The keyword Slide refers to how often you want a result. In Figure 1-3, the Range specification indicates "I want to look at 5 seconds worth of data" and the Slide specification indicates "I want a result every 5 seconds".

Figure 1-3 Range and Slide

Description of Figure 1-3 follows
Description of "Figure 1-3 Range and Slide"

The keyword Partition By logically partitions a data stream S into different substreams based on the equality of the attributes given in the Partition By specification. For example, the S[Partition By A,C Rows 2] partition specification creates a sub-stream for every unique combination of A and C value pairs and the Rows specification is applied on these sub-streams. The Rows specification indicates "I want to look at 2 tuples worth of data". By default, the range (and slide) is 1 second.

For more information, see:

1.1.4 Relation-to-Stream Operators

You can convert the result of a stream-to-relation operation back into a stream for further processing.

In Example 1-8, the select will output a stream of tuples satisfying the filter condition (viewq3.ACCT_INTRL_ID = ValidLoopCashForeignTxn.ACCT_INTRL_ID). The now window converts the viewq3 into a relation, which is kept as a relation by the filter condition. The IStream relation-to-stream operator converts the output of the filter back into a stream.

Example 1-8 Relation-to-Stream Operation

<processor>
    <name>cqlProcessor</name>
    <rules>
        <query id="q3Txns"><![CDATA[ 
            IStream(
                select 
                    TxnId, 
                    ValidLoopCashForeignTxn.ACCT_INTRL_ID, 
                    TRXN_BASE_AM, 
                    ADDR_CNTRY_CD, 
                    TRXN_LOC_ADDR_SEQ_ID 
                from 
                    viewq3[NOW], ValidLoopCashForeignTxn 
                where 
                    viewq3.ACCT_INTRL_ID = ValidLoopCashForeignTxn.ACCT_INTRL_ID
            )
        ]]></query>
    </rules>
</processor>

Oracle CQL supports the following relation-to-stream operators:

By default, Oracle CEP includes an operation indicator in the relations it generates so you can identify insertions, deletions, and, when using UPDATE SEMANTICS, updates. For more information, see Section 1.1.1.3, "Relations and Oracle CEP Tuple Kind Indicator".

1.1.5 Stream-to-Stream Operators

There are no specific operators for stream to stream operations. Instead, you perform stream to stream operations using the following:

However, some relation-relation operators (like filter and project) can also act as stream-stream operators. Consider the query that Example 1-9 shows: assuming that the input S is a stream, the query will produce a stream as an output where stream element c1 is greater than 50.

Example 1-9 Stream-to-Stream Operation

<processor>
    <name>cqlProcessor</name>
    <rules>
        <query id="q0"><![CDATA[ 
            select * from S where c1 > 50
        ]]></query>
    </rules>
</processor>

In addition, Oracle CQL supports the following direct stream-to-stream operators:

1.1.6 Queries, Views, and Joins

An Oracle CQL query is an operation that you express in Oracle CQL syntax and execute on an Oracle CEP CQL processor to retrieve data from one or more streams, relations, or views. A top-level SELECT statement that you create in a <query> element is called a query. For more information, see Section 14.2, "Queries".

An Oracle CQL view represents an alternative selection on a stream or relation. In Oracle CQL, you use a view instead of a subquery. A top-level SELECT statement that you create in a <view> element is called a view. For more information, see Section 14.3, "Views".

A join is a query that combines rows from two or more streams, views, or relations. For more information, see Section 14.4, "Joins".

For more information, see Chapter 14, "Oracle CQL Queries, Views, and Joins".

1.1.7 Pattern Recognition

The Oracle CQL MATCH_RECOGNIZE construct is the principle means of performing pattern recognition.

A sequence of consecutive events or tuples in the input stream, each satisfying certain conditions constitutes a pattern. The pattern recognition functionality in Oracle CQL allows you to define conditions on the attributes of incoming events or tuples and to identify these conditions by using String names called correlation variables. The pattern to be matched is specified as a regular expression over these correlation variables and it determines the sequence or order in which conditions should be satisfied by different incoming tuples to be recognized as a valid match.

For more information, see Chapter 15, "Pattern Recognition With MATCH_RECOGNIZE".

1.1.8 Event Sources and Event Sinks

An Oracle CEP event source identifies a producer of data that your Oracle CQL queries operate on. An Oracle CQL event sink identifies a consumer of query results.

This section explains the types of event sources and sinks you can access in your Oracle CQL queries and how you connect event sources and event sinks.

1.1.8.1 Event Sources

An Oracle CEP event source identifies a producer of data that your Oracle CQL queries operate on.

In Oracle CEP, the following elements may be event sources:

  • adapter (JMS, HTTP, and file)

  • channel

  • processor

  • cache

  • relational database table


Note:

In Oracle CEP, you must use a channel to connect an event source to an Oracle CQL processor and to connect an Oracle CQL processor to an event sink. A channel is optional with other Oracle CEP processor types. For more information, see Section 1.1.1, "Streams and Relations".

Oracle CEP event sources are typically push data sources: that is, Oracle CEP expects the event source to notify it when the event source has data ready.

Oracle CEP table and cache event sources are pull data sources: that is, Oracle CEP will periodically poll the event source.

Using an Oracle CQL processor, you can specify a relational database table as an event source. You can query this event source, join it with other event sources, and so on. For more information, see:

  • "Configuring Access to a Relational Database" in the Oracle CEP Administrator's Guide

  • "Configuring an Oracle CQL Processor Table Source" in the Oracle CEP IDE Developer's Guide for Eclipse

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. For more information, see:

  • "Configuring Caching" in the Oracle CEP IDE Developer's Guide for Eclipse

  • "Configuring an Oracle CQL Processor Cache Source" in the Oracle CEP IDE Developer's Guide for Eclipse

  • "Oracle Continuous Query Language (CQL) Example" in the Oracle CEP Getting Started

1.1.8.2 Event Sinks

An Oracle CQL event sink connected to a CQL processor is a consumer of query results.

In Oracle CEP, the following elements may be event sinks:

  • adapter (JMS, HTTP, and file)

  • channel

  • processor

  • cache

You can associate the same query with more than one event sink and with different types of event sink.

1.1.8.3 Connecting Event Sources and Event Sinks

In Oracle CEP, you define event sources and event sinks using Oracle CEP IDE for Eclipse to create the Event Processing Network (EPN) as Figure 1-4 shows. In this EPN, adapter PriceAdapter is the event source for channel priceStream; channel priceStream is the event source for Oracle CQL processor filterFanoutProcessor. Similarly, Oracle CQL processor filterFanoutProcessor is the event sink for channel priceStream.

Figure 1-4 Event Sources and Event Sinks in the Event Processing Network

Description of Figure 1-4 follows
Description of "Figure 1-4 Event Sources and Event Sinks in the Event Processing Network"

For more information, see:

1.1.9 Functions

Functions are similar to operators in that they manipulate data items and return a result. Functions differ from operators in the format of their arguments. This format enables them to operate on zero, one, two, or more arguments:

function(argument, argument, ...) 

A function without any arguments is similar to a pseudocolumn (refer to Chapter 3, "Pseudocolumns"). However, a pseudocolumn typically returns a different value for each tuple in a relation, whereas a function without any arguments typically returns the same value for each tuple.

Oracle CQL provides a wide variety of built-in functions to perform operations on stream data, including:

  • single-row functions that return a single result row for every row of a queried stream or view

  • aggregate functions that return a single aggregate result based on group of tuples, rather than on a single tuple

  • single-row statistical and advanced arithmetic operations based on the Colt open source libraries for high performance scientific and technical computing.

  • aggregate statistical and advanced arithmetic operations based on the Colt open source libraries for high performance scientific and technical computing.

  • statistical and advanced arithmetic operations based on the java.lang.Math class

If Oracle CQL built-in functions do not provide the capabilities your application requires, you can easily create user-defined functions in Java by using the classes in the oracle.cep.extensibility.functions package. You can create aggregate and single-row user-defined functions. You can create overloaded functions and you can override built-in functions.

If you call an Oracle CQL function with an argument of a datatype other than the datatype expected by the Oracle CQL function, then Oracle CEP attempts to convert the argument to the expected datatype before performing the Oracle CQL function.

For more information, see:

1.1.10 Time

Timestamps are an integral part of an Oracle CEP stream. However, timestamps do not necessarily equate to clock time. For example, time may be defined in the application domain where it is represented by a sequence number. Timestamps need only guarantee that updates arrive at the system in the order of increasing timestamp values.

Note that the timestamp ordering requirement is specific to one stream or a relation. For example, tuples of different streams could be arbitrarily interleaved.

Oracle CEP can observe application time or system time.

To configure application timestamp or system timestamp operation, see child element application-timestamped in "wlevs:channel" in the Oracle CEP IDE Developer's Guide for Eclipse.

For system timestamped relations or streams, time is dependent upon the arrival of data on the relation or stream data source. Oracle CEP generates a heartbeat on a system timestamped relation or stream if there is no activity (no data arriving on the stream or relation's source) for more than a specified time: for example, 1 minute. Either the relation or stream is populated by its specified source or Oracle CEP generates a heartbeat every minute. This way, the relation or stream can never be more than 1 minute behind.

To configure a heartbeat, see "heartbeat" in the Oracle CEP IDE Developer's Guide for Eclipse.

For system timestamped streams and relations, the system assigns time in such a way that no two events will have the same value of time. However, for application timestamped streams and relations, events could have same value of time.

If you know that the application timestamp will be strictly increasing (as opposed to non-decreasing) you may set wlevs:channel attribute is-total-order to true. This enables the Oracle CEP engine to do certain optimizations and typically leads to reduction in processing latency.

To configure is-total-order, see "wlevs:application-timestamped" in the Oracle CEP IDE Developer's Guide for Eclipse.

The Oracle CEP scheduler is responsible for continuously executing each Oracle CQL query according to its scheduling algorithm and frequency.

For more information on the scheduler, see "scheduler" in the Oracle CEP IDE Developer's Guide for Eclipse.

1.2 Oracle CQL Statements

Oracle CQL provides statements for creating the following:

For more information, see:

1.2.1 Oracle CQL Statement Lexical Conventions

Using Oracle CEP IDE for Eclipse or Oracle CEP Visualizer, you write Oracle CQL statements in the XML configuration file associated with an Oracle CEP CQL processor. This XML file is called the configuration source.

The configuration source must conform with the wlevs_application_config.xsd schema and may contain only rule, view, or query elements as Example 1-10 shows.

Example 1-10 Typical Oracle CQL Processor Configuration Source File

<?xml version="1.0" encoding="UTF-8"?>
<n1:config xsi:schemaLocation="http://www.bea.com/ns/wlevs/config/application wlevs_application_config.xsd" 
    xmlns:n1="http://www.bea.com/ns/wlevs/config/application" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<processor>
    <name>cqlProcessor</name>
    <rules>
        <view id="lastEvents" schema="cusip bid srcId bidQty ask askQty seq"><![CDATA[ 
            select cusip, bid, srcId, bidQty, ask, askQty, seq 
            from inputChannel[partition by srcId, cusip rows 1]
        ]]></view>
        <view id="bidask" schema="cusip bid ask"><![CDATA[ 
            select cusip, max(bid), min(ask) 
            from lastEvents
            group by cusip
        ]]></view>
            <view ...><![CDATA[
                ...
        ]]></view>
        ...
        <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>
        <query id="BBAQuery"><![CDATA[ 
            ISTREAM(select bba.cusip, bba.bidseq, bba.bidSrcId, bba.bid, bba.askseq, bba.askSrcId, bba.ask, bba.bidQty, bba.askQty, "BBAStrategy" as intermediateStrategy, p.seq as correlationId, 1 as priority 
            from MAXBIDMINASK as bba, inputChannel[rows 1] as p where bba.cusip = p.cusip)
        ]]></query>
    </rules>
</processor>

When writing Oracle CQL queries in an Oracle CQL processor component configuration file, observe the following rules:

  • You may specify one Oracle CQL statement per rule, view, or query element.

  • You must not terminate Oracle CQL statements with a semicolon.

  • You must enclose each Oracle CQL statement in <![CDATA[ and ]]> as Example 1-10 shows.

  • When you issue an Oracle CQL statement, you can include one or more tabs, carriage returns, or spaces anywhere a space occurs within the definition of the statement. Thus, Oracle CEP evaluates the Oracle CQL statement in Example 1-11 and Example 1-12 in the same manner.

    Example 1-11 Oracle CQL: Without Whitespace Formatting

    <processor>
        <name>cqlProcessor</name>
        <rules>
            <query id="QTollStr"><![CDATA[ 
                RSTREAM(select cars.car_id, SegToll.toll from CarSegEntryStr[now] as cars, SegToll where (cars.exp_way = SegToll.exp_way and cars.lane = SegToll.lane and cars.dir = SegToll.dir and cars.seg = SegToll.seg))
            ]]></query>
        </rules>
    </processor>
    

    Example 1-12 Oracle CQL: With Whitespace Formatting

    <processor>
        <name>cqlProcessor</name>
        <rules>
            <query id="QTollStr"><![CDATA[ 
                RSTREAM(
                    select
                        cars.car_id, 
                        SegToll.toll 
                    from 
                        CarSegEntryStr[now]
                    as
                        cars, SegToll 
                    where (
                        cars.exp_way = SegToll.exp_way and 
                        cars.lane = SegToll.lane and 
                        cars.dir = SegToll.dir and 
                        cars.seg = SegToll.seg
                    )
                )
            ]]></query>
        </rules>
    </processor>
    
  • Case is insignificant in reserved words, keywords, identifiers and parameters. However, case is significant in text literals and quoted names.

    For more information, see:

  • Comments are not permitted in Oracle CQL statements. For more information, see Section 2.7, "Comments".


Note:

Throughout the Oracle CEP CQL Language Reference, Oracle CQL statements are shown only with their rule, view, or query element for clarity.

1.2.2 Oracle CQL Statement Documentation Conventions

All Oracle CQL statements in this reference (see Chapter 16, "Oracle CQL Statements") are organized into the following sections:

Syntax The syntax diagrams show the keywords and parameters that make up the statement.


Caution:

Not all keywords and parameters are valid in all circumstances. Be sure to refer to the "Semantics" section of each statement and clause to learn about any restrictions on the syntax.

Purpose The "Purpose" section describes the basic uses of the statement.

Prerequisites The "Prerequisites" section lists privileges you must have and steps that you must take before using the statement.

Semantics The "Semantics" section describes the purpose of the keywords, parameter, and clauses that make up the syntax, and restrictions and other usage notes that may apply to them. (The conventions for keywords and parameters used in this chapter are explained in the Preface of this reference.)

Examples The "Examples" section shows how to use the various clauses and parameters of the statement.

1.3 Oracle CQL and SQL Standards

Oracle CQL is a new technology but it is based on a subset of SQL99.

Oracle strives to comply with industry-accepted standards and participates actively in SQL standards committees. Oracle is actively pursuing Oracle CQL standardization.

1.4 Oracle CEP Server and Tools Support

Using the Oracle CEP server and tools, you can efficiently create, package, deploy, debug, and manage Oracle CEP applications that use Oracle CQL.

1.4.1 Oracle CEP Server

Oracle CEP server provides the light-weight Spring container for Oracle CEP applications and manages server and application lifecycle, provides a JRockit real-time JVM with deterministic garbage collection, and a wide variety of essential services such as security, Jetty, JMX, JDBC, HTTP publish-subscribe, and logging and debugging.

For more information on Oracle CEP server, see Oracle CEP Administrator's Guide.

1.4.2 Oracle CEP Tools

Oracle CEP provides the following tools to facilitate your Oracle CQL development process:

  • Oracle CEP IDE for Eclipse: an Eclipse-based integrated development environment supporting the complete lifecycle of development for Oracle CEP applications, including Oracle CQL syntax highlighting and validation, graphical Event Processing Network editor, and efficient management of component and application assembly configuration files.

    For more information, see Oracle CEP IDE Developer's Guide for Eclipse.

  • Oracle CEP Visualizer: a rich graphical user interface for Oracle CEP that provides runtime configuration and administration of Oracle CEP applications, queries, caching, and clustering.

    For more information, see Oracle CEP Visualizer User's Guide.