EPL Reference: Clauses 2-23
2.13.1 General Usage
You use question marks in a parameterized EPL query to indicate the location of a place holder. You can use placeholders in any expression where a constant value is
currently allowed; you put the placeholder in the same location as the constant would be. In practice this means that you can specify placeholders only in the SELECT and
WHERE clauses of a query. You cannot use placeholders in the RETAIN clause.
The following example shows a parameterized query: SELECT symbol, AVGprice AS average, ? AS market
FROM StockTick t RETAIN ALL EVENTS WHERE symbol = ?
The example shows how to specify a placeholder in both the SELECT and WHERE clause. At runtime, the two placeholders are bound with values, such as NASDAQ and
ORCL so that the actual EPL statement that is executed looks like the following:
SELECT symbol, AVGprice AS average, NASDAQ AS market FROM StockTick t RETAIN ALL EVENTS
WHERE symbol = ORCL
2.13.2 Using a Parameterized EPL Statement in the Processor Configuration File
If you have configured the EPL rules for a particular processor in its component configuration file, you specify the EPL statement as usual using the rule element.
Specify the placeholders using question marks, as described in Section 2.13.1, General
Usage. Then use the binding element to specify one or more params elements that
correspond to the comma-separated list of values that you want to pass to the parameterized EPL statement at runtime. Each params element effectively causes a
new EPL query to execute with the new parameters. Use the id attribute of binding to reference the particular EPL rule to which the binding applies. Each
params element contains a single set of parameters; the order of the parameters corresponds to the order in which the question marks appear in the parameterized
query.
Use the id attribute of params to uniquely identify each individual parameter set; this is so later you can dynamically delete single parameter sets using JMX or
wlevs.Admin.
As with the EPL rules in the configuration file, group the binding elements together using a parent bindings element.
The following example shows how to specify a parameterized query and its runtime parameters for the query described in
Section 2.13.1, General Usage :
n1:config xmlns:n1=http:www.bea.comnswlevsconfigapplication xmlns:xsi=http:www.w3.org2001XMLSchema-instance
processor namemyProcessorname
rules rule id=MarketRule[CDATA[
SELECT symbol, AVGprice AS average, ? AS market FROM StockTick t RETAIN ALL EVENTS
WHERE symbol = ? ]]rule
rules bindings
binding id=MarketRule
2-24 Oracle Complex Event Processing EPL Language Reference
params id=nasORCLNASDAQ,ORCLparams params id=nyJPMNYSE,JPMparams
params id=nyWFCNYSE,WFCparams binding
bindings processor
n1:config In the preceding example, the MarketRule EPL query includes two placeholders: one
in the SELECT clause and another in the WHERE clause. The binding id=MarketRule element specifies the list of parameter sets that will be passed to
MarketRule at runtime. Each parameter set is specified with a single params element. Because there are two placeholders in the parameterized query, each
params element specifies two values separated by a comma.
At runtime, the preceding parameterized query effectively breaks down into the following three queries
SELECT symbol, AVGprice AS average, NASDAQ AS market FROM StockTick t RETAIN ALL EVENTS
WHERE symbol = ORCL SELECT symbol, AVGprice AS average, NYSE AS market
FROM StockTick t RETAIN ALL EVENTS WHERE symbol = JPM
SELECT symbol, AVGprice AS average, NYSE AS market FROM StockTick t RETAIN ALL EVENTS
WHERE symbol = WFC
2.13.3 Programmatically Using a Prepared EPL Statement