Excerpted from http://blog.csdn.net/milife2013/article/details/8660205
DB2 string connection is the same as the Oracle database, using the "| |" Make a DB2 string connection, using the same way as the plus sign "+" in MSSQLServer. For example, execute the following SQL statement:
SELECT ' work number is ' | | fnumber| | ' The employee's name is ' | | FName from T_employee
WHERE FName is not NULL
In addition to the "| |", DB2 also supports string concatenation using the concat () function, such as executing the following SQL statement:
SELECT CONCAT (' Work number: ', fnumber) from T_employee
Unlike Oracle, if the value connected in Concat is not a string, DB2 does not attempt to type-convert but to report an error message, such as executing the following SQL statement:
SELECT CONCAT (' Age: ', Fage) from T_employee
After running, DB2 will report the following error message:
A licensed example with a compatible argument is not found with a type of "FUNCTION" named "CONCAT"
Unlike MySQL's concat () function, the DB2 concat () function supports only two parameters and does not support stitching of more than two strings, such as the following SQL statement is wrong in Oracle:
SELECT CONCAT (' Work number ', Fnumber, ' Employee name ', FName) from T_employee
WHERE FName is not NULL
After running, Oracle will report the following error message:
An authorized routine named "CONCAT" with compatible arguments is not found for type "FUNCTION"
If you want to make multiple strings of stitching, you can use multiple concat () functions nested, the above SQL can be rewritten as follows:
SELECT CONCAT (CONCAT (CONCAT (' Work number ', Fnumber), ' Employee Name '), FName) from
T_employee
WHERE FName is not NULL
DB2 string concatenation in front of field plus 0 Operation 0| | ' Field name '