SQL/MX 2.x Reference Manual (H06.04+)

SQL/MX Functions and Expressions
HP NonStop SQL/MX Reference Manual540440-003
9-28
CONCAT Function
CONCAT Function
The CONCAT function returns the concatenation of two character value expressions as
a character string value. You can also use the concatenation operator (||).
CONCAT is an SQL/MX extension.
character-expr-1, character-expr-2
are SQL character value expressions (of data type CHAR or VARCHAR) that
specify two strings of characters. The result of the CONCAT function is the
concatenation of character-expr-1 with character-expr-2. See Character
Value Expressions on page 6-37.
Concatenation Operator (||)
The concatenation operator, denoted by two vertical bars (||), concatenates two string
values to form a new string value. To indicate that two strings are concatenated,
connect the strings with two vertical bars (||):
character-expr-1 || character-expr-2
An operand can be any SQL value expression of data type CHAR or VARCHAR.
Considerations for CONCAT
Operands
A string value can be specified by any character value expression, such as a character
string literal, character string function, column reference, aggregate function, scalar
subquery, CASE expression, or CAST expression. The value of the operand must be
of type CHAR or VARCHAR.
If you use the CAST expression, you must specify the length of CHAR or VARCHAR.
SQL Parameters
You can concatenate an SQL parameter and a character value expression. The
concatenated parameter takes on the data type attributes of the character value
expression. Consider this example, where ?p is assigned a string value of
'5 March':
?p || ' 2002'
The type assignment of the parameter ?p becomes CHAR(5), the same data type as
the character literal ' 2002'. Because you assigned a string value of more than five
characters to ?p, NonStop SQL/MX returns a truncation warning, and the result of the
concatenation is 5 Mar 2002.
CONCAT (character-expr-1, character-expr-2)