Case Data Query Language (DQL)
DQL is used to define query expressions that can be used as parameters in the findByCriteria methods to search for case references that match the criteria defined by the query expression.
DQL expressions use the syntax:
attributeName operator value
where:
- attributeName can be specified either as a simple name, or as an attribute path, which uses dot notation to navigate around the data model
- operator is one of the supported operators.
- value is the value to match against, which can use wildcards, constants and parameters.
For example:
name = "Tony Pulis"
Compound Expressions
Simple expressions can be combined with AND or OR to make more complicated expressions. For example, to match records that contain a '?' in the address attribute where the name starts with 'Fred', or, the name starts with Bill:
address = "London" AND name = "Fred" OR name = "Bill"
Normal operator precedence applies (AND is highest and OR is lowest) and can be overridden with the use of brackets. The example just given would be evaluated as:
((address = "London") AND (name = "Fred")) OR (name = "Bill")
AND and OR are case-insensitive.
When a compound expression refers to attributes that have multiplicity in their path, then the conditions are required to match the same object. For example, consider the following classes:
The following query requires a single orderline to match both conditions - it would not match if one orderline satisfies the first condition and another satisfies the second:
orderLines.quantity > 100 and orderLines.partNum = ‘1350CNW’
This query would not, therefore, match an order with the following orderLines:
If you want to allow conditions to match different members, you can assign tags to the part of the attribute path that has multiplicity. Tags consist of a dollar sign followed by a letter, optionally followed by further numbers and letters. Assigning different tags to each condition removes the need for them to match the same object, so the following query would match the order described above.
orderLines[$a].quantity > 100 and orderLines[$b].partNum = ‘1350CNW’
Similarly, to find an order with one orderline for 150 x ADR460 and another for 75 x 1350CNW, the following query could be used:
orderLines[$x].quantity = 150 and orderLines[$x].partNum = ‘ADR460’ and orderLines[$y].quantity = 75 and orderLines[$y].partNum = ‘1350CNW’
Sort Order
You can add an ORDER BY clause to the end of the DQL statement to specify what order the records should be returned in. The format of the ORDER BY clause is:
[ORDER BY column ASC|DESC[, column ASC|DESC][..]]
Each column specification is a multiplicity-single attribute path followed by one of the keywords ASC or DESC.
For example, to find all the customers with the name "Blogs" and sort by name then address:
name = "%Blogs" ORDER BY name ASC, address asc
Reserved Words
You can use a reserved word in a query expression if you wrap the reserved word in curly brackets.
{type} = 1Similarly, if you have a parameter called "type", you must wrap the reserved word in curly brackets, as shown below.
myAttribute = :{type}
{type}[ALL] = 1