Apama Documentation : Developing Apama Applications : Developing Apama Applications in EPL : Defining Queries : Implementing parameterized queries : Parameterized queries as templates
Parameterized queries as templates
When a parameterized query is injected into a correlator no instances of the query are created until a request to create a parameterization is sent using the Scenario Service (that is, the com.apama.services.scenario client API). This request must include valid values for the query's parameters. For example, if the query in the previous topic is injected, the request to create a parameterization must include valid values for the product, thresholdCost, and warrantyPeriod parameters. Only then does the query become active.
A parameterized query lets you define a generic query find pattern that operates on a particular group of input types and that can be customized for particular criteria. The query in the previous topic could be created for any product with the threshold cost and warranty period specified as required. To achieve the same result with a non-parameterized query, you would have to define a query such as the following:
query FaultyProduct {
inputs {
Sale() key customerId within 1 week; //warrantyPeriod
Repair() key customerId retain 1;
}
find Sale():s1 w-> Repair():r1
where s1.productId = "Mobile device A" // productId
and r1.productId = "Mobile device A" // productId
and r1.cost >= 50.00 // thresholdCost
{
log "Cost of warranty covered repair for product \"Mobile device A\
" above threshold $50.00 by $" + (r1.cost - 50.00).toString() at INFO;
}
}
While this query is valid it has the drawback that whenever you want to perform a similar query for a product that differs by type, warranty coverage period or threshold repair cost then a new query will need to be written (or most likely copied and pasted) with the new set of values and then injected into the correlator. The benefit of a parameterized query is that only one query definition needs to be injected into the correlator and you can then manually or programatically create as many different instances for the different product-value combinations as required.
Copyright © 2013-2016 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback