Oracle CQL Built-in Datatypes

Basic Elements of Oracle CQL 2-3

2.2.2 Handling Other Datatypes Using Oracle CQL Data Cartridges

If your event uses a datatype that Oracle CQL does not support, you can use an Oracle CQL data cartridge to evaluate that datatype in an Oracle CQL query. Oracle CQL includes the following data cartridges: ■ Chapter 15, Oracle Java Data Cartridge ■ Chapter 16, Oracle Spatial ■ Chapter 17, Oracle CEP JDBC Data Cartridge For more information, see Chapter 14, Introduction to Data Cartridges .

2.2.3 Handling Other Datatypes Using a User-Defined Function

If your event uses a datatype that Oracle CQL does not support, you can create a user-defined function to evaluate that datatype in an Oracle CQL query. Consider the enum datatype that Example 2–1 shows. The event that Example 2–2 shows uses this enum datatype. Oracle CQL does not support enum datatypes. Example 2–1 Enum Datatype ProcessStatus package com.oracle.app; public enum ProcessStatus { CHAR[size] 1 Variable-length character data of length size characters. Maximum size is 4096 characters. Default and minimum size is 1 character. For more information, see Section 2.4.1, Text Literals . DOUBLE Fixed-length number equivalent to a Java double type. For more information, see Section 2.4.2, Numeric Literals . FLOAT Fixed-length number equivalent to a Java float type. For more information, see Section 2.4.2, Numeric Literals . INTEGER Fixed-length number equivalent to a Java int type. For more information, see Section 2.4.2, Numeric Literals . INTERVAL Fixed-length INTERVAL datatype specifies a period of time. Oracle CEP supports DAY TO SECOND. Maximum length is 64 bytes. For more information, see Section 2.4.4, Interval Literals . TIMESTAMP Fixed-length TIMESTAMP datatype stores a datetime literal that conforms to one of the java.text.SimpleDateFormat format models that Oracle CQL supports. Maximum length is 64 bytes. For more information, see Section 2.4.3, Datetime Literals . XMLTYPE Use this datatype for stream elements that contain XML data. Maximum length is 4096 characters. XMLTYPE is a system-defined type, so you can use it as an argument of a function or as the datatype of a stream attribute. For more information, see SQLXML SQLX on page 5-16. OBJECT This stands for any Java object that is, any subclass of java.lang.Object. We refer to this as opaque type support in Oracle CEP since the Oracle CEP engine does not understand the contents of an OBJECT field. You typically use this type to pass values, from an adapter to its destination, as-is; these values need not be interpreted by the Oracle CEP engine such as Collection types or any other user-specific Java type but that are associated with the event whose other fields are referenced in a query. 1 Oracle CQL supports single-dimension arrays only. Table 2–1 Cont. Oracle CQL Built-in Datatype Summary Oracle CQL Datatype Description 2-4 Oracle Complex Event Processing CQL Language Reference OPEN1, CLOSED0} } Example 2–2 Event Using Enum Datatype ProcessStatus package com.oracle.app; import com.oracle.capp.ProcessStatus; public class ServiceOrder { private String serviceOrderId; private String electronicSerialNumber; private ProcessStatus status; ... } By creating the user-defined function that Example 2–3 shows and registering the function in your application assembly file as Example 2–4 shows, you can evaluate this enum datatype in an Oracle CQL query as Example 2–5 shows. Example 2–3 User-Defined Function to Evaluate Enum Datatype package com.oracle.app; import com.oracle.capp.ProcessStatus; public class CheckIfStatusClosed { public boolean executeObject[] args { ProcessStatus arg0 = ProcessStatusargs[0]; if arg0 == ProcessStatus.OPEN return Boolean.FALSE; else return Boolean.TRUE; } } Example 2–4 Registering the User-Defined Function in Application Assembly File wlevs:processor id=testProcessor wlevs:listener ref=providerCache wlevs:listener ref=outputCache wlevs:cache-source ref=testCache wlevs:function function-name=statusClosed exec-method=”execute” bean class=com.oracle.app.CheckIfStatusClosed wlevs:function wlevs:processor Example 2–5 Using the User-Defined Function to Evaluate Enum Datatype in an Oracle CQL Query query id=rule-04[CDATA[ SELECT meter.electronicSerialNumber, meter.exceptionKind FROM MeterLogEvent AS meter, ServiceOrder AS svco WHERE meter.electronicSerialNumber = svco.electronicSerialNumber and svco.serviceOrderId IS NULL OR statusClosedsvco.status ]]query For more information, see Chapter 13, User-Defined Functions .