ARTICLE
Filter Conditions
A filter condition is a logical expression that compares the attributes
of a persistent class with free parameters or values. The syntax of a
filter condition is based on the syntax of the Open SQL WHERE
condition, whereby reference variables for object references are
also supported. Like a WHERE condition, a filter condition is
made up of elementary comparisons that can be joined using the boolean
operators AND , OR , and NOT , where grouping using
parentheses is supported.
When a query is executed using a class actor, the query is bound
precisely to its persistent class. The attributes specified in a filter
condition must be available in the persistent class as public persistent
attributes, otherwise an exception occurs. On the other hand, a query
that has been created can certainly be executed in succession by class
actors of different persistent classes, as long as the specified
attributes are available. When a query is executed, a SELECT
statement is created internally with a WHERE condition, in which
the attributes are replaced by concrete column identifiers and the free
parameters are replaced by current values.
The elementary relational operators below are supported in a filter
condition. An attribute, attr , of a persistent class must be
specified as the first operand of a condition. The second operand
operand or pattern of a comparison may be an attribute, a
parameter par , or a literal value.
The names of parameters can be defined freely by specifying a parameter
list, which is a list of parameter names that can be used in the filter
condition. The parameter�s position in the parameter list defines the
parameter�s index in the parameter table. If no parameter list is
specified, a predefined parameter list with the three parameter names
PAR1 , PAR2 , and PAR3 is used.
Literal values are generally enclosed by quotation marks. The semantics
of the relational operators are defined by the corresponding Open
SQL language element into which the logical expression is converted.
Note
The filter condition and its parameter list are analyzed when a query is
executed and transformed into an internal display. To avoid parsing each
time the query is executed, the methods of the interface
IF_OS_QUERY_EXPR_FACTORY can be used to create multiple-use filter
conditions in the internal representation.
Security notes
Specifying a subroutine dynamically is one of the dynamic programming
techniques.
To avoid SQL injections , we
recommend the use of parameters from the parameter list of a chaining,
where dyanmic values are represented as literals.
See also SQL Injections Using Object
Services .
Relational Operators
attr =| | | | =| = { operand }
LIKE
attr [NOT] LIKE { pattern } [ESCAPE escape]
IS NULL
attr IS [NOT] NULL
EQUALSREF
attr EQUALSREF par
Comparison of two object references. When the query is executed,
parameter par has to be bound to a reference variable that refers
to a persistent instance of a persistent class.
AND , OR , NOT
NOT expr
expr AND expr
expr OR expr
The semantics of the boolean operators AND , OR , and
NOT are also defined by their semantics in Open SQL . Explicit
parentheses are possible. If no parentheses are specified, the Open
SQL priority rules apply.
Examples
price '100' AND currency = 'EUR'
name LIKE PAR1 AND age '45' AND age '65'
( department EQUALSREF DEP1 OR department EQUALSREF DEP2 ) AND NOT
( salary '50000' AND currency = 'EUR' ) )
Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved