Multiple Parameter JDBC Cartridge Context Functions Using the Oracle CEP

17-12 Oracle Complex Event Processing CQL Language Reference function jc:jdbc-ctx

17.2.2 Defining Oracle CQL Queries With the Oracle CEP JDBC Data Cartridge

This section describes how to define Oracle CQL queries that invoke SQL statements using the Oracle CEP JDBC data cartridge, including: ■ Section 17.2.2.1, Using SELECT List Aliases ■ Section 17.2.2.2, Using the TABLE Clause ■ Section 17.2.2.3, Using a Native CQL Type as a return-component-type For more information, see Configuring Oracle CQL Processors in the Oracle Complex Event Processing Developers Guide for Eclipse.

17.2.2.1 Using SELECT List Aliases

Consider the Oracle CEP JDBC data cartridge context function that Example 17–12 shows. Example 17–12 Oracle CEP JDBC Data Cartridge Context Function jc:jdbc-ctx nameJdbcCartridgeOnename data-sourceStockDSdata-source function name=getDetailsByOrderIdName param name=inpOrderId type=int param name=inpName type=char return-component-type com.oracle.cep.example.jdbc_cartridge.RetEvent return-component-type sql[CDATA[ SELECT Employee.empName as employeeName, Employee.empEmail as employeeEmail, OrderDetails.description as description FROM PlacedOrders, OrderDetails , Employee WHERE PlacedOrders.empId = Employee.empId AND PlacedOrders.orderId = OrderDetails.orderId AND Employee.empName = :inpName AND PlacedOrders.orderId = :inpOrderId ]]sql function jc:jdbc-ctx You must assign an alias to each column in the SELECT list. When you invoke the JDBC cartridge context function in an Oracle CQL query, you access the columns in the result set by their SQL SELECT list aliases. For more information, see Section 17.2.2.2, Using the TABLE Clause .

17.2.2.2 Using the TABLE Clause

Consider the Oracle CEP JDBC data cartridge SQL statement that Example 17–13 shows. Example 17–13 Oracle CEP JDBC Data Cartridge SQL Statement ... jc:jdbc-ctx Oracle CEP JDBC Data Cartridge 17-13 nameJdbcCartridgeOnename data-sourceStockDSdata-source function name=getDetailsByOrderIdName param name=inpOrderId type=int param name=inpName type=char return-component-type com.oracle.cep.example.jdbc_cartridge.RetEvent return-component-type sql[CDATA[ SELECT Employee.empName as employeeName, Employee.empEmail as employeeEmail, OrderDetails.description as description FROM PlacedOrders, OrderDetails , Employee WHERE PlacedOrders.empId = Employee.empId AND PlacedOrders.orderId = OrderDetails.orderId AND Employee.empName = :inpName AND PlacedOrders.orderId = :inpOrderId ]]sql function jc:jdbc-ctx ... The Oracle CQL query in Example 17–14 invokes the JDBC cartridge context function that Example 17–13 defines. Example 17–14 Oracle CQL Query Invoking an Oracle CEP JDBC Data Cartridge Context Function processor nameProcname rules query id=q1[CDATA[ RStream select currentOrder.orderId, details.orderInfo.employeeName, details.orderInfo.employeeemail, details.orderInfo.description details.orderInfo.getEmployeeNameLength from OrderArrival[now] as currentOrder, TABLEgetDetailsByOrderIdNameJdbcCartridgeOne currentOrder.orderId, currentOrder.empName as orderInfo as details ]]query rules processor You must wrap the Oracle CEP JDBC data cartridge context function invocation in an Oracle CQL query TABLE clause. You access the result set using: TABLE_CLAUSE_ALIAS .JDBC_CARTRIDGE_FUNCTION_ALIAS.SQL_SELECT_LIST_ALIAS or TABLE_CLAUSE_ALIAS .JDBC_CARTRIDGE_FUNCTION_ALIAS.METHOD_NAME Where: ■ TABLE_CLAUSE_ALIAS : the outer AS alias of the TABLE clause.