Skip to main content

Literals

Literals

InterSystems SQL literals have the following syntax:

literal ::=       number | string-literal  number ::=        {digit}[.]digit{digit}[E[+|-]digit{digit}]   digit ::=      0..9  string-literal ::=       std-string-literal | ObjectScript-empty-string  std-string-literal ::=       ' {std-character-representation} '  std-character-representation ::=      nonquote-character | quote-symbol  quote-symbol ::=       ''  ObjectScript-empty-string ::=       ""

A literal is a series of characters that represents an actual (literal) value. It can be either a number or a character string.

  • A number does not require any delimiter character. It can consist of the digits 0 through 9, the decimal point character, the exponent symbol and the plus and minus signs. Only one decimal point character can be used in a number. This decimal point can only be used in the base portion of a number, not in the exponent portion. The decimal point does not need to be followed by a digit. Leading and trailing zeros are permitted. The exponent (scientific notation) symbol is the letter E; both uppercase and lowercase E are accepted, but uppercase E is the preferred usage. A plus or minus sign can prefix a base number or an exponent. Multiple plus and minus signs can prefix a base number; SQL treats these signs as operators. Only a single plus or minus sign can prefix an exponent; SQL treats this sign as part of the literal. No commas or blanks are permitted in a number.

  • A character string literal consists of a pair of delimiter characters enclosing a string of characters of any type. The preferred delimiter character is the single-quote character (see below). To specify a delimiter character as a literal within a character string, double the character; for example: 'Mary''s office'.

The empty string is a literal string; it is represented by two single-quote characters (''). NULL is not a literal value; it represents the absence of any value. For further details, see NULL and the Empty String.

Note:

In Embedded SQL, a few character sequences that begin with ## are not permitted within a string literal, as described in Literal Values. This restriction does not apply to other invocations of SQL, such as Dynamic SQL.

String Delimiters

Use single quote (') characters as string delimiters. The use of the double-quote character (") is supported for SQL compatibility, but this use is strongly discouraged because of conflict with the delimited identifier standard. A pair of double quote characters "" is parsed as an invalid delimited identifier and generates an SQLCODE -1 error.

To specify a single quote character as a literal character within a string, specify a pair of these characters as the literal escape sequence. For example, 'a ''normal'' string'.

Concatenation

The double vertical bar (||) is the preferred SQL concatenation operator. It can be used to concatenate two numbers, two character strings, or a number and a character string.

The underscore (_) is provided as an SQL concatenation operator for ObjectScript compatibility. This concatenation operator can only be used to concatenate two character strings.

If the two operands are both character strings, and both strings have the same collation type, the resulting concatenated string has that collation type. In all other cases, the result of concatenation is of collation type EXACT.

FeedbackOpens in a new tab