Neoview SQL Reference Manual (R2.5)

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 a Neoview SQL extension.
CONCAT (character-expr-1, character-expr-2)
character-expr-1, character-expr-2
are SQL character value expressions (of data type CHAR or VARCHAR) that specify two
strings of characters. Both character value expressions must be either ISO8859-1 character
expressions or UCS2 character expressions. The result of the CONCAT function is the
concatenation of character-expr-1 with character-expr-2. The result type is CHAR
if both expressions are of type CHAR and it is VARCHAR if either of the expressions is of
type VARCHAR. See “Character Value Expressions” (page 255).
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, Neoview
SQL returns a truncation warning, and the result of the concatenation is 5 Mar 2002.
To specify the type assignment of the parameter, use the CAST expression on the parameter as:
CAST(?p AS CHAR(7)) || '2002'
In this example, the parameter is not truncated, and the result of the concatenation is 5 March
2002.
Examples of CONCAT
Insert information consisting of a single character string. Use the CONCAT function to
construct and insert the value:
INSERT INTO stats.logfile
(user_key, user_info)
VALUES (001, CONCAT ('Executed at ',
CAST (CURRENT_TIMESTAMP AS CHAR(26))));
Use the concatenation operator || to construct and insert the value:
364 SQL Functions and Expressions