| This is documentation for Semarchy xDM 2024.3, which is no longer supported. For more information, see our Global Support and Maintenance Policy. |
SemQL syntax
The SemQL syntax supports the equivalent of SQL expressions, conditions or ORDER BY clauses, which are a combination of one or more values, operators, and functions.
Tokens
Values, operators, and functions are the tokens in the SemQL language.
-
Values are simple expressions, which include:
-
literals are constant values. Numerics are provided as is, other literals must be enclosed in single quotes (e.g.,
'John',-42, or'1994-11-07'). -
Attributes refer to attributes of the entities in the model.
-
Model variables contain values that are used to customize the user experience or parameterize an integration job.
-
Search parameters store the values entered in a search form and submitted to the search condition attached to the search form. Search parameters are available only in their own search form’s condition.
-
-
Operators modify, combine, or compare expressions. SemQL supports most SQL operators, including arithmetic and character operators (
+,-,*,/,||), comparison operators (=,!=,>,>=,<,⇐,IN,BETWEEN,LIKE,REGEXP_LIKE,IS NULL), and logical operators (AND,OR,NOT). -
Functions and expression constructs combine other tokens to create new expressions.
Case sensitivity differs for the language tokens:
-
Operators are not case-sensitive.
-
Functions are not case-sensitive for Oracle and PostgreSQL, but are case-sensitive for SQL Server.
-
Values (attribute, parameter, and variable names) are always case-sensitive.
-
StartYear BETWEEN 2012 and 2014is equivalent toStartYear Between 2012 AND 2014. -
UPPER( CustomerName )is equivalent toUpper( CustomerName ).. -
customerNameandCustomERNamedo not represent the same attribute in an entity.
Phrases
Expressions, conditions and ORDER BY clauses are the phrases supported by the SemQL language.
-
Expressions combine values, operators and functions to return a non-boolean value.
-
Conditions combine values, operators and functions to return a boolean value (
trueorfalse). -
ORDER BYclauses are expressions used to sort data by ascending or descending values of the expression.
TheASCorDESCpostfixes define the sort order. The default sort order is ascending.
ORDER BYclauses in the consolidation rules' Ranking Expression also support theNULLS FIRSTorNULLS LASTclauses to specify whether null values should be ordered before or after non-null values. By default, theORDER BYclause usesNULLS LASTif the sort isASCandNULLS FIRSTif the sort isDESC.
-
FirstNameis an attribute. -
'USA'is a string literal. -
Initcap(FirstName)is a function using an attribute. -
Initcap(FirstName) || ' ' || Initcap(LastName)is a combination of operators, functions, attributes, and literals.
-
1=1compares two literals. -
Country='USA'compares an attribute and a literal. -
Upper(Country) in ('USA', 'US', 'CANADA')uses a function.
ORDER BY clauses-
Countrysorts by the Country attribute (ascending by default). -
Country DESCsorts by the Country attribute (descending). Null values are sorted (default behavior forDESC) before all non-null values. -
Country DESC NULLS LASTsorts by the Country attribute (descending). Null values are sorted after all non-null values. -
CASE PublisherID WHEN 'MKT' THEN 1 WHEN 'CRM' THEN 2 ELSE 99 END ASCsorts records where PublisherID equalsMKT, thenCRM, then the rest.