How to Configure an Oracle CQL Processor Using Oracle CEP IDE for Eclipse

10-6 Oracle Complex Event Processing Developers Guide wlevs:processor 4. Add a rules child element to each processor element. Use the rules element to group the child elements you create to contain the Oracle CQL statements this processor executes, including: ■ rule: contains Oracle CQL statements that register or create user-defined windows. The rule element id attribute must match the name of the window. ■ view: contains Oracle CQL view statements the Oracle CQL equivalent of subqueries. The view element id attribute defines the name of the view. ■ query: contains Oracle CQL select statements. The query element id attribute defines the name of the query. Use the required id attribute of the view and query elements to uniquely identify each rule. Use the XML CDATA type to input the actual Oracle CQL rule. For example: ?xml version=1.0 encoding=UTF-8? n1:config xsi:schemaLocation=http:www.bea.comnswlevsconfigapplication wlevs_ application_config.xsd xmlns:n1=http:www.bea.comnswlevsconfigapplication xmlns:xsi=http:www.w3.org2001XMLSchema-instance processor nameprocname rules view id=lastEvents schema=cusip bid srcId bidQty[CDATA[ select modprice from filteredStream[partition by srcId, cusip rows 1] ]]view query id=q1[CDATA[ SELECT FROM lastEvents [Now] WHERE price 10000 ]]query rules processor n1:config]]query 5. Save and close the file. 6. Optionally, configure additional Oracle CQL processor features in the assembly file: ■ Section 10.1.1, Controlling Which Queries Output to a Downstream Channel ■ Section 10.3, Configuring an Oracle CQL Processor Table Source ■ Section 10.4, Configuring an Oracle CQL Processor Cache Source Caution: Identifiers and names in XML files are case sensitive, so be sure you specify the same case when referencing the components identifier in the EPN assembly file. Configuring Oracle CQL Processors 10-7

10.3 Configuring an Oracle CQL Processor Table Source

You can configure an Oracle CQL processor to access a table in a relational database as an event stream in which each row in the table is represented as a tuple. In this section, assume that you create the table you want to access using the SQL statement that Example 10–4 shows. Example 10–4 Table Create SQL Statement create table Stock symbol varchar16, exchange varchar16; After configuration, you can define Oracle CQL queries that access the Stock table as if it was just another event stream. In the following example, the query joins one event stream ExchangeStream with the Stock table: Example 10–5 Oracle CQL Query on Relational Database Table Stock SELECT ExchangeStream.symbol, ExchangeStream.price, Stock.exchange FROM ExchangeStream [Now], Stock WHERE ExchangeStream.symbol = Stock.symbol

10.3.1 How to Configure an Oracle CQL Processor Table Source Using Oracle CEP IDE for Eclipse

The most efficient and least error-prone way to configure an Oracle CQL processor to access a relational database table is to use the Oracle CEP IDE for Eclipse. To configure an Oracle CQL processor table source using Oracle CEP IDE for Eclipse: 1. Create a data source for the database that contains the table you want to use. Example 10–6 shows an example Oracle CEP server config.xml file with data source StockDS. Example 10–6 Oracle CEP Server config.xml File With Data Source StockDS ?xml version=1.0 encoding=UTF-8? n1:config xsi:schemaLocation=http:www.bea.comnswlevsconfigserver wlevs_server_ config.xsd xmlns:n1=http:www.bea.comnswlevsconfigserver xmlns:xsi=http:www.w3.org2001XMLSchema-instance domain nameocep_domainname domain Note: Because changes in the table source are not coordinated in time with stream data, you may only join the table source to an event stream using a Now window and you may only join to a single database table. To integrate arbitrarily complex SQL queries and multiple tables with your Oracle CQL queries, consider using the Oracle JDBC data cartridge instead. For more information, see Understanding the Oracle JDBC Data Cartridge in the Oracle Complex Event Processing CQL Language Reference.