How to Create an Oracle CQL Template for the Query Wizard

Managing Oracle CQL Rules 6-67 where-block Operator ID=5 type=Join Operator where-block Rule 4. Connect your operators together by adding inputs elements as Example 6–4 shows. Example 6–4 Rule Element: Connect Operators ?xml version=1.0 encoding=UTF-8? Rule root=9 select-block Operator ID=10 type=Output inputs input9input inputs Operator Operator ID=9 type=IStream inputs input8input inputs Operator Operator ID=7 type=Select inputs input5input inputs Operator select-block from-block Operator ID=1 type=SSource Operator Operator ID=2 type=Window inputs input1input inputs Operator Operator ID=3 type=SSource Operator Operator ID=4 type=Window inputs input3input inputs Operator from-block where-block Operator ID=5 type=Join inputs input2input input4input inputs 6-68 Oracle Complex Event Processing Visualizer Users Guide Operator where-block Rule 5. Save and close your template XML file. 6. Copy your template XML file to the ORACLE_CEP_HOMEuser_ projectsdomainsDOMAIN_DIRservernamecqltemplate directory of your Oracle CEP server, where ORACLE_CEP_HOME refers to the Oracle CEP installation directory such as d:\oracle_cep, DOMAIN_DIR refers to the name of your domain directory, and servername refers to the name of your server. For example: d:\oracle_cep_home\user_ projects\domains\mydomain\myserver1\cqltemplate . 7. Add the name of your template XML file to the ORACLE_CEP_HOMEuser_ projectsdomainsDOMAIN_ DIRservernamecqltemplateregistry.xml file. Example 6–5 shows how to register the template XML file example.xml. Example 6–5 Oracle CEP registry.xml File ?xml version=1.0 encoding=UTF-8? templates template nameexamplename filenameexample.xmlfilename descriptionThis is an example user-defined cql statementdescription template templates The template element name child element determines the title that the Query Wizard displays in the User-defined templates tab for this template. 8. Exit out of the Oracle CEP Visualizer and log back in. For more information, see Section 2.1, Starting the Oracle CEP Visualizer .

9. Open the Oracle CQL Query Wizard and locate your template in the User-defined

templates tab as Figure 6–76 shows. Note: If you enter double-byte characters in your template XML file, ensure that you save the file using UTF-8 encoding. For more information, see Section 1.5.1, Configuration File Encoding: UTF-8 . Managing Oracle CQL Rules 6-69 Figure 6–76 Query Wizard User-defined templates Tab For more information, see Section 6.1.1, How to Create a Rule in an Oracle CQL Processor Using the Query Wizard .

6.1.11 Managing the Query Wizard Diagram

This section describes the various tools along the top of the Query Wizard canvas as Figure 6–77 shows. Figure 6–77 Query Wizard Tools You use these tools to manage the Query Wizard diagram of your Oracle CQL statement.

6.1.11.1 Choose Layout

Use the Choose Layout pull-down menu to select alternate ways of distributing CQL constructs and showing their dependencies. You can choose any of: ■ Left-Right ■ Bottom-Top ■ Right-Left ■ Top-Bottom 6-70 Oracle Complex Event Processing Visualizer Users Guide

6.1.11.2 Clear Canvas

Click the Clear Canvas button to erase the current Oracle CQL statement and its diagram from the Query Wizard canvas.

6.1.11.3 Save Query

Click the Save Query button at any time even if you have not yet completed your Oracle CQL statement to save your work to your local disk instead of the host.

6.1.11.4 Open Query

Click the Open Query button to reload a previously saved query.

6.1.11.5 Hover

Check the Hover option to display the Oracle CQL statement fragment associated with a given stage when you hover your mouse pointer over that stage. Uncheck the Hover option to disable this feature.

6.1.11.6 Zoom In and Zoom Out

Click the Zoom In and Zoom Out buttons to change the zoom level. This is an alternative to using the Zoom slider see Section 6.1.11.9, Zoom .

6.1.11.7 Fit Content

Click the Fit Content button to adjust the zoom level automatically to make all of the diagram visible in the current browser window.

6.1.11.8 Toggle Constructs

Click the Toggle Constructs button to alternately hide and show the CQL Constructs and Templates gallery.

6.1.11.9 Zoom

Use the Zoom slider to increase or decrease the zoom level. This is an alternative to using the Zoom In and Zoom Out buttons see Section 6.1.11.6, Zoom In and Zoom Out .

6.2 Using the Query Plan

Oracle CEP Visualizer provides a sophisticated Query Plan facility to simplify Oracle CQL query optimization. Using the Query Plan facility, you can decompose a given Oracle CQL processor into its internal operators, states, and synopsis and you can gather various statistics on these operators such as incoming and outgoing number of messages. The Query Plan facility generates one query plan per Oracle CQL processor and applies to all the queries and views you define on that Oracle CQL processor. The Oracle CQL Query Plan facility is designed to allow system administrators to efficiently diagnose and optimize Oracle CQL query performance. This section describes the following topics: ■ Section 6.2.1, How to View a Query Plan for an Oracle CQL Processor Managing Oracle CQL Rules 6-71

6.2.1 How to View a Query Plan for an Oracle CQL Processor

You can view a query plan for an Oracle CQL processor using the Oracle CEP Visualizer. To view a query plan for an Oracle CQL processor: 1. In the left pane, navigate to and expand the Applications node of the Oracle CEP instance to which the application is deployed.

2. Select appname, where appname is the name of the application you want to use.

3. Select the Oracle CQL processor you wish to use:

a. To use the EPN diagram:

– Click the Event Processing Network tab. – Double-click the Oracle CQL processor you wish to use.

b. To use the domain tree:

– Expand the appname Stages node, where appname is the name of the application you want to use. – Click the Oracle CQL processor you wish to use. – In the right pane, click the General tab The Processor panel is displayed as Figure 6–1 shows. Note: Before Oracle CEP Visualizer can generate a query plan, there must be at least one running Oracle CQL query with the Running attribute set to true on the Oracle CQL processor. For more information, see Section 6.1.8, How to View a Rule in an Oracle CQL Processor .