Overloading JDBC Cartridge Context Functions Using the Oracle CEP JDBC data

17-14 Oracle Complex Event Processing CQL Language Reference In Example 17–14 , details. ■ JDBC_CARTRIDGE_FUNCTION_ALIAS : the inner AS alias of the JDBC cartridge context function. In Example 17–14 , oderInfo. ■ SQL_SELECT_LIST_ALIAS : the JDBC cartridge context function SELECT list alias. In Example 17–13 , employeeName, employeeEmail, and description. ■ METHOD_NAME : the name of the method that the return-component-type class provides. In Example 17–14 , getEmployeeNameLength. As Example 17–14 shows, you access the JDBC cartridge context function result set in the Oracle CQL query using: details.orderInfo.employeeName details.orderInfo.employeeemail details.orderInfo.description details.orderInfo.getEmployeeNameLength The component type of the collection type returned by the JDBC data cartridge function is defined by the function element return-component-type child element. Because the function is always called from within an Oracle CQL TABLE clause, it always returns a collection type. If the getDetailsByORderIdName JDBC cartridge context function called in Example 17–14 is defined as Example 17–13 shows, then orderInfo is of type com.oracle.cep.example.jdbc_ cartridge.RetEvent. You can access both fields and methods of the return-component-type in an Oracle CQL query. In Example 17–13 , the return-component-type specifies a Java bean implemented as Example 17–15 shows. Example 17–15 Example return-component-type Class package com.oracle.cep.example.jdbc_cartridge; public class RetEvent { String employeeName; String employeeEmail; String description; Default constructor is mandatory public RetEvent1 {} May contain getters and setters for the fields public String getEmployeeName { return this.employeeName; } public void setEmployeeNameString employeeName { this.employeeName = employeeName; } ... May contain other helper methods public int getEmployeeNameLength { Oracle CEP JDBC Data Cartridge 17-15 return employeeName.length; } } This class provides helper methods, like getEmployeeNameLength, that you can invoke within the Oracle CQL query. For more information, see: ■ Section 17.2.1.2.2, return-component-type ■ Section 18.2.7, Function TABLE Query ■ table_clause on page 20-10

17.2.2.3 Using a Native CQL Type as a return-component-type

Following is a JDBC cartridge context that defines a function that has a native CQL type bigint as return-component-type. Example 17–16 CQL Type bigint as a return-component-type jc:jdbc-ctx nameJdbcCartridgeOnename data-sourcemyJdbcDataSourcedata-source function name=getOrderAmt param name=inpId type=int return-component-typebigintreturn-component-type -- native CQL as return component type -- sql[CDATA[ SELECT getOrderAmt:inpId as orderAmt FROM select :inpId as iid from dual]] sql function jc:jdbc-ctx Example 17–17 shows how the getOrderAmt function in Example 17–16 can be used in a CQL query. Example 17–17 getOrderAmt Function in a CQL Query query id=q1[CDATA[ RStream select currentOrder.orderId, details.orderInfo as orderAmt from OrderArrival[now] as currentOrder, TABLEgetOrderAmtJdbcCartridgeTwocurrentOrder.orderId as orderInfo of bigint as details ]]query Note that the alias orderInfo itself is of type bigint and can be accessed as details.orderInfo as orderAmt in the select list of the CQL query. The of bigint clause used inside the TABLE construct is optional. If specified, the type mentioned should match the return-component-type, which is bigint in Example 17–16 .