How to Create an Oracle CQL Processor Component Configuration File Manually

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. 10-8 Oracle Complex Event Processing Developers Guide ... data-source nameStockDsname connection-pool-params initial-capacity1initial-capacity max-capacity10max-capacity connection-pool-params driver-params urljdbc:derby:url driver-nameorg.apache.derby.jdbc.EmbeddedDriverdriver-name properties element namedatabaseNamename valuedbvalue element element namecreatename valuetruevalue element properties driver-params data-source-params jndi-names elementStockDselement jndi-names global-transactions-protocolNoneglobal-transactions-protocol data-source-params data-source ... n1:config For more information, see Configuring Access to a Relational Database in the Oracle Complex Event Processing Administrators Guide. 2. Use Oracle CEP IDE for Eclipse to create a table node. See Section 6.4.1.1, How to Create a Basic Node . 3. Use Oracle CEP IDE for Eclipse to create an Oracle CQL processor. See Section 6.4.1.3, How to Create a Processor Node . 4. Connect the table node to the Oracle CQL processor node. See Section 6.4.2.1, How to Connect Nodes . The EPN Editor adds a wlevs:table-source element to the target processor node that references the source table.

5. Right-click the table node in your EPN and select Go to Assembly Source.

Oracle CEP IDE for Eclipse opens the EPN assembly file for this table node. 6. Edit the table element as Example 10–7 shows and configure the table element attributes as shown in Table 10–1 . Example 10–7 EPN Assembly File table Element wlevs:table id=Stock event-type=StockEvent data-source=StockDs Configuring Oracle CQL Processors 10-9

7. Right-click the Oracle CQL processor node connected to the table in your EPN and

select Go to Assembly Source. Oracle CEP IDE for Eclipse opens the EPN assembly file for this Oracle CQL processor.

8. Edit the Oracle CQL processor element’s table-source child element as

Example 10–8 shows. Set the ref attribute to the id of the table element you specified in step 6. Example 10–8 EPN Assembly File table-source Element wlevs:processor id=proc wlevs:table-source ref=Stock wlevs:processor 9. Edit the EPN assembly file to update the event-type-repository element with a new event-type child element for the table as Example 10–9 shows. Create a property child element for each column of the table you want to access and configure the property attributes as shown in Table 10–2 . Example 10–9 EPN Assembly File event-type element for a Table wlevs:event-type-repository ... wlevs:event-type type-name=StockEvent wlevs:properties wlevs:property name=symbol type=char[] length=16 wlevs:property name=exchange type=char[] length=16 wlevs:properties wlevs:event-type ... wlevs:event-type-repository Table 10–1 EPN Assembly File table Element Attributes Attribute Description id The name of the table source. Subsequent references to this table source use this name. event-type The type-name you specify for the table event-type you create in step 9. data-source The data-source name you specified in the Oracle CEP server config.xml file in step 1. Table 10–2 EPN Assembly File event-type Element Property Attributes Attribute Description name The name of the table column you want to access as specified in the SQL create table statement. You do not need to specify all columns. type The Oracle CEP Java type from Table 10–3 that corresponds to the column’s SQL data type. In Example 10–4 , the type value for column symbol is char[]. length The column size as specified in the SQL create table statement. In Example 10–4 , the length of column symbol is 16. 10-10 Oracle Complex Event Processing Developers Guide For more information on creating event types, see: ■ Chapter 2.1.4, Creating Oracle CEP Event Types ■ Section 2.1.3, Event Type Data Types 10. Right-click the Oracle CQL processor node connected to the table in your EPN and select Go to Configuration Source. Table 10–3 SQL Column Types and Oracle CEP Type Equivalents SQL Type Oracle CEP Java Type com.bea.wlevs.ede.api.Type Description ARRAY [Ljava.lang.Object Array, of depth 1, of java.lang.Object. BIGINT java.math.BigInteger bigint An instance of java.math.BigInteger. BINARY byte[] Array, of depth 1, of byte. BIT java.lang.Boolean boolean An instance of java.lang.Boolean. BLOB byte[] Array, of depth 1, of byte. BOOLEAN java.lang.Boolean boolean An instance of java.lang.Boolean. CHAR java.lang.Character char An instance of java.lang.Character. CLOB byte[] Array, of depth 1, of byte. DATE java.sql.Date timestamp An instance of java.sql.Date. DECIMAL java.math.BigDecimal An instance of java.math.BigDecimal. BINARY_DOUBLE 1 or DOUBLE 2 1 Oracle SQL. 2 Non-Oracle SQL. java.lang.Double double An instance of java.lang.Double BINARY_FLOAT 1 or FLOAT 2 java.lang.Double float An instance of java.lang.Double INTEGER java.lang.Integer int An instance of java.lang.Integer. JAVA_OBJECT java.lang.Object object An instance of java.lang.Object. LONGNVARCHAR char[] char Array, of depth 1, of char. LONGVARBINARY byte[] Array, of depth 1, of byte. LONGVARCHAR char[] char Array, of depth 1, of char. NCHAR char[] char Array, of depth 1, of char. NCLOB byte[] Array, of depth 1, of byte. NUMERIC java.math.BigDecimal An instance of java.math.BigDecimal. NVARCHAR char[] char Array, of depth 1, of char. OTHER java.lang.Object object An instance of java.lang.Object. REAL java.lang.Float float An instance of java.lang.Float SMALLINT java.lang.Integer int An instance of java.lang.Integer. SQLXML xmltype xmltype For more information on processing XMLTYPE data in Oracle CQL, see SQLXML SQLX in the Oracle Complex Event Processing CQL Language Reference. TIME java.sql.Time An instance of java.sql.Time. TIMESTAMP java.sql.Timestamp timestamp An instance of java.sql.Timestamp. TINYINT java.lang.Integer int An instance of java.lang.Integer. VARBINARY byte[] Array, of depth 1, of byte. VARCHAR char[] char Array, of depth 1, of char.