Those expressions may use a subset of SQL, extended with the possibility to use program variables in the SQL expression. The allowed SQL expressions are defined with the BNF-grammar below.
The following notational conventions are made:
Expression ::= FilterExpression | TopicExpression | QueryExpression . FilterExpression ::= Condition TopicExpression ::= SelectFrom { Where } ';' QueryExpression ::= { Condition }{ 'ORDER BY' (FIELDNAME // ',') } .SelectFrom ::= 'SELECT' Aggregation 'FROM' Selection . Aggregation ::= '*' | (SubjectFieldSpec // ',') . SubjectFieldSpec ::= FIELDNAME | FIELDNAME 'AS' IDENTIFIER | FIELDNAME IDENTIFIER . Selection ::= TOPICNAME | TOPICNAME NaturalJoin JoinItem . JoinItem ::= TOPICNAME | TOPICNAME NaturalJoin JoinItem | '(' TOPICNAME NaturalJoin JoinItem ')' . NaturalJoin ::= 'INNER JOIN' | 'INNER NATURAL JOIN' | 'NATURAL JOIN' | 'NATURAL INNER JOIN' . Where ::= 'WHERE' Condition . Condition ::= Predicate | Condition 'AND' Condition | Condition 'OR' Condition | 'NOT' Condition | '(' Condition ')' . Predicate ::= ComparisonPredicate | BetweenPredicate . ComparisonPredicate ::= ComparisonTerm RelOp ComparisonTerm . ComparisonTerm ::= FieldIdentifier | Parameter . BetweenPredicate ::= FieldIdentifier 'BETWEEN' Range | FieldIdentifier 'NOT BETWEEN' Range . FieldIdentifier ::= FIELDNAME | IDENTIFIER . RelOp ::= '=' | '>' | '>=' | '<' | '<=' | '<>' | 'LIKE' | 'MATCH' . Range ::= Parameter 'AND' Parameter . Parameter ::= INTEGERVALUE | CHARVALUE | FLOATVALUE | STRING | ENUMERATEDVALUE | BOOLEANVALUE | PARAMETER .
Note -- INNER JOIN, INNER NATURAL JOIN, NATURAL JOIN, and NATURAL INNER JOIN are all aliases, in the sense that they have the same semantics. They are all supported because they all are part of the SQL standard.
Formal notation:
IDENTIFIER: LETTER (PART_LETTER)* where LETTER: [ "A"-"Z","_","a"-"z" ] PART_LETTER: [ "A"-"Z","_","a"-"z","0"-"9" ]
Formal notation:
FIELDNAME: FieldNamePart ( "." FieldNamePart )* where FieldNamePart : IDENTIFIER ( "[" Index "]" )* Index> : (["0"-"9"])+ | ["0x","0X"](["0"-"9", "A"-"F", "a"-"f"])+
Primitive IDL types referenced by FIELDNAME are treated as different types in Predicate according to the following table:
Predicate Data Type | IDL Type |
BOOLEANVALUE | boolean |
INTEGERVALUE | octet, (unsigned) short, (unsigned) long, (unsigned) long long |
FLOATVALUE | float, double |
CHARVALUE | char, wchar |
STRING | string, wstring |
ENUMERATEDVALUE | enum |
Formal notation:
TOPICNAME : IDENTIFIER
Formal notation:
INTEGERVALUE : (["+","-"])? (["0"-"9"])+ [("L","l")]? | (["+","-"])? ["0x","0X"](["0"-"9", "A"-"F", "a"-"f"])+ [("L","l")]?
Formal notation:
CHARVALUE : "'" (~["'"])? "'"
Formal notation:
FLOATVALUE : (["+","-"])? (["0"-"9"])* (".")? (["0"-"9"])+ (EXPONENT)? where EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+
Formal notation:
STRING : "'" (~["'"])* "'"
Formal notation:
ENUMERATEDVALUE : "'" ["A" - "Z", "a" - "z"] ["A" - "Z", "a" - "z", "_", "0" - "9"]* "'"
Formal notation (case insensitive):
BOOLEANVALUE : ["TRUE","FALSE"]
Formal notation:
PARAMETER : "%" (["0"-"9"])+
" symbol MATCH %0 " with parameter 0 = " 'IBM' "whereas the following expression will not compile:
" symbol MATCH '%0' " with parameter 0 = " IBM "
BOOLEANVALUE | INTEGERVALUE | FLOATVALUE | CHARVALUE | STRING | ENUMERATEDVALUE | |
BOOLEAN | YES | |||||
INTEGERVALUE | YES | YES | ||||
FLOATVALUE | YES | YES | ||||
CHARVALUE | YES | YES | YES | |||
STRING | YES | YES(*1) | YES | |||
ENUMERATEDVALUE | YES | YES(*2) | YES(*2) | YES(*3) |
MATCH is case-sensitive.
The pattern allows limited "wild card" matching under the following rules:
Character | Meaning |
, | "," separates a list of alternate patterns. The field string is matched if it matches one or more of the patterns. |
/ | "/"in the pattern string matches a / in the field string. This character is used to separate a sequence of mandatory substrings. |
? | "?" in the pattern string matches any single non-special characters in the field string. |
* | "*" in the pattern string matches 0 or more non-special characters in field string. |
[charlist] | Matches any one of the characters from the list of characters in charlist. |
[s-e] | Matches any character any character from s to e, inclusive. |
% | "%" is used to designate filter expressions parameters. |
[!charlist] or [^charlist] | Matches any characters not in charlist (not supported). |
[!s-e] or [^s-e] | Matches any characters not in the interval [s-e] (not supported). |
</b> | Escape character for special characters (not supported) |
The syntax is similar to the POSIX fnmatch syntax (1003.2-1992 section B.6). The MATCH syntax is also similar to the 'subject' strings of TIBCO Rendezvous.
Example of a filter_expression (for DDS.ContentFilteredTopic) or a query_expression (for DDS.QueryCondition):
"z < 1000 AND x < 23"
Examples of a filter_expression using MATCH (for DDS.ContentFilteredTopic) operator:
"symbol MATCH 'NASDAQ/GOOG'"
"symbol MATCH 'NASDAQ/[A-M]*'"
Example of a topic_expression (for DDS.MultiTopic Not supported):
"SELECT flight_id, x, y, z AS height FROM 'Location' NATURAL JOIN 'FlightPlan' WHERE height < 1000 AND x <23"