2.10.2.6.3. JPQL String Functions
-
functions_returning_strings ::= CONCAT(string_primary, string_primary) | SUBSTRING(string_primary, simple_arithmetic_expression[, simple_arithmetic_expression]) | TRIM([[trim_specification] [trim_character] FROM] string_primary) | LOWER(string_primary) | UPPER(string_primary) | REPLACE(string_expression, string_expression, string_expression) | LEFT(string_expression, arithmetic_expression) | RIGHT(string_expression, arithmetic_expression)
-
trim_specification ::= LEADING | TRAILING | BOTH
-
functions_returning_numerics ::= LENGTH(string_primary) | LOCATE(string_primary, string_primary[, simple_arithmetic_expression])
The CONCAT function returns a string that is a concatenation of its arguments.
The second and third arguments of the SUBSTRING function denote the starting position and length of the substring to be returned.
These arguments are integers.
The third argument is optional.
If it is not specified, the substring from the start position to the end of the string is returned.
The first position of a string is denoted by 1.
The SUBSTRING function returns a string.
The TRIM function trims the specified character from a string.
If the character to be trimmed is not specified, it is assumed to be space (or blank). The optional trim_character is a single-character string literal or a character-valued input parameter (i.e., char or Character). If a trim specification is not provided, BOTH is assumed.
The
TRIM function returns the trimmed string.
The LOWER and UPPER functions convert a string to lower and upper case, respectively.
They return a string.
The LOCATE function returns the position of a given string within a string, starting the search at a specified position.
It returns the first position at which the string was found as an integer.
The first argument is the string to be located; the second argument is the string to be searched; the optional third argument is an integer that represents the string position at which the search is started (by default, the beginning of the string to be searched). The first position in a string is denoted by 1.
If the string is not found, 0 is returned.
Note that not all databases support the use of a trim character other than the space character; use of this argument may result in queries that are not portable.
Note that not all databases support the use of the third argument to LOCATE; use of this argument may result in queries that are not portable.
The LENGTH function returns the length of the string in characters as an integer.