Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 11.0.1 » QAnywhere » QAnywhere Reference » QAnywhere transmission and delete rules » Rule syntax

 

Condition syntax

QAnywhere conditions use a SQL-like syntax. Conditions are evaluated against messages in the message store. A condition evaluates to true, false, or unknown. If a condition is empty, all messages are judged to satisfy the condition. Conditions can be used in transmission rules, delete rules, and the QAnywhere programming APIs.

Keywords and string comparisons are case insensitive.

Syntax
condition :
expression IS [ NOT ] NULL
| expression compare expression
| expression [ NOT ] BETWEEN expression AND expression 
| expression [ NOT ] LIKE pattern [ ESCAPE character ]
| expression [ NOT ] IN ( string, ...  ) 
| NOT condition
| condition AND condition
| condition OR condition
| ( condition )
compare: = |> | < | >= | <= | <>
expression:
constant
| rule-variable
| -expression
| expression operator expression
| ( expression )
| rule-function ( expression, ... )
constant: integer | floating point number | string | boolean
integer: An integer in the range -2**63 to 2**63-1.
floating point number: A number in scientific notation in the range 2.2250738585072e-308 to 1.79769313486231e+308.
string: A sequence of characters enclosed in single quotes. A single quote in a string is represented by two consecutive single quotes.
boolean: A statement that is TRUE or FALSE, T or F, Y or N, 1 or 0.
operator: + | - | * | /
rule-variable: 

See Rule variables.

rule-function: 

See Rule functions.

Parameters
  • BETWEEN   The BETWEEN condition can evaluate as true, false, or unknown. Without the NOT keyword, the condition evaluates as true if expression is greater than or equal to the start expression and less than or equal to the end expression.

    The NOT keyword reverses the meaning of the condition but leaves UNKNOWN unchanged.

    The BETWEEN condition is equivalent to a combination of two inequalities:

    [ NOT ] ( expression >= start-expression AND arithmetic-expression <= end-expr )
    

    For example:

    • age BETWEEN 15 AND 19 is equivalent to age >=15 AND age <= 19

    • age NOT BETWEEN 15 AND 19 is equivalent to age < 15 OR age > 19.

  • IN   The IN condition evaluates according to the following rules:

    • True if expression is not null and equals at least one of the values in the list.

    • Unknown if expression is null and the values list is not empty, or if at least one of the values is null and expression does not equal any of the other values.

    • False if none of the values are null, and expression does not equal any of the values in the list.

    The NOT keyword interchanges true and false.

    For example:

    • Country IN ( 'UK', 'US', 'France' ) is true for 'UK' and false for 'Peru'. It is equivalent to the following:

      ( Country = 'UK' )       \
      OR ( Country = 'US' )    \
      OR ( Country = 'France' )
    • Country NOT IN ( 'UK', 'US', 'France' ) is false for 'UK' and true for 'Peru'. It is equivalent to the following:

      NOT ( ( Country = 'UK' )         \
            OR ( Country = 'US' )      \
            OR ( Country = 'France' ) )

  • LIKE   The LIKE condition can evaluate as true, false, or unknown.

    Without the NOT keyword, the condition evaluates as true if expression matches the like expression. If either expression or like expression is null, this condition is unknown.

    The NOT keyword reverses the meaning of the condition, but leaves unknown unchanged.

    The like expression may contain any number of wildcards. The wildcards are:

    Wildcard Matches
    _ (underscore) Any one character
    % (percent) Any string of zero or more characters

    For example:

    • phone LIKE 12%3 is true for '123' or '12993' and false for '1234'

    • word LIKE 's_d' is true for 'sad' and false for 'said'

    • phone NOT LIKE '12%3' is false for '123' or '12993' and true for '1234'

  • ESCAPE CHARACTER   The ESCAPE CHARACTER is a single character string literal whose character is used to escape the special meaning of the wildcard characters (_, %) in pattern. For example:

    • underscored LIKE '\_%' ESCAPE '\' is true for '_myvar' and false for 'myvar'.

  • IS NULL   The IS NULL condition evaluates to true if the rule-variable is unknown; otherwise it evaluates to false. The NOT keyword reverses the meaning of the condition. This condition cannot evaluate to unknown.