String functions

EQL supports the following string functions.

Function Description
CONCAT Concatenates two or more string arguments into a single string.
SUBSTR Returns a part (substring) of a character expression.
TO_STRING Converts a value to a string.

CONCAT function

CONCAT is a row function that returns a string that is the result of concatenating two or more string values. Its syntax is:
CONCAT(string1, string2 [, stringN])

Each argument can be a literal string (within single quotation marks), an attribute of type string, or any expression that produces a string.

This sample query uses three literal strings for the arguments:
RETURN results AS 
SELECT
  CONCAT('Jane ', 'Amanda ', 'Wilson') AS FullName
FROM EmployeeState
GROUP
This similar query uses two string-type attributes, plus a quoted space to separate the customer's first and last names:
RETURN results AS 
SELECT
   ARB(CONCAT(CUST_FIRST_NAME, ' ', CUST_LAST_NAME)) AS CustomerName
FROM EmployeeState
GROUP

SUBSTR function

The SUBSTR function has two syntaxes:
SUBSTR(string, position)

SUBSTR(string, position, length)
where:
  • string is the string to be parsed.
  • position is a number that indicates where the substring starts (see below for details).
  • length is a number that specifies the length of the substring that is to be extracted. If length is omitted, EQL returns all characters to the end of string. If length is less than 1, EQL returns NULL.
The position argument is treated as follows:
  • If position is 0, it is treated as 1.
  • If position is positive, then it is counted from the beginning of string to find the first character.
  • If position is negative, the EQL counts backward from the end of string.
  • If position is greater than the length of string, EQL returns the empty string.

Note that position is not zero indexed. For example, in order to start with the fifth character, position must be 5.

TO_STRING function

The TO_STRING function takes an integer value and returns a string equivalent. Its syntax is:
TO_STRING(int)

If the input value is NULL, the output value will also be NULL.

This sample query converts the value of the P_SIZE integer attribute to a string equivalent:
RETURN results AS 
SELECT
  ARB(TO_STRING(P_SIZE)) AS Sizes
FROM ProductState
GROUP