Implementation of DB2 string connection

Source: Internet
Author: User

The DB2 string connection is the same as that of the oracle database. The DB2 string connection is performed using "|", which is the same as the plus sign "+" in MSSQLServer. For example, execute the following SQL statement:
SELECT 'employee ID is '| FNumber |' employee name is '| FName FROM T_Employee
WHERE FName IS NOT NULL

In addition to "|", DB2 also supports String concatenation using the CONCAT () function, such as executing the following SQL statement:
Select concat ('employee ID: ', FNumber) FROM T_Employee

Unlike Oracle, if the connected value in CONCAT is not a string, DB2 will not try to type conversion but report an error message. For example, the following SQL statement is incorrect:
Select concat ('Age: ', FAge) FROM T_Employee

After running DB2, the following error message is returned:
No authorized instance with compatible independent variables named "FUNCTION" CONCAT "is found

Unlike MYSQL's CONCAT () function, DB2's CONCAT () function only supports two parameters and does not support concatenation of two or more strings. For example, the following SQL statement is incorrect in Oracle:
Select concat ('employee ID is ', FNumber,' employee name is ', FName) FROM T_Employee
WHERE FName IS NOT NULL
After running Oracle, the following error message is displayed:
Authorization routines with compatible independent variables named "FUNCTION" CONCAT "not found

To splice multiple strings, you can use multiple CONCAT () functions for nesting. The preceding SQL statement can be rewritten as follows:
Select concat ('employee ID is ', FNumber),' employee name is '), FName) FROM
T_Employee
WHERE FName IS NOT NULL
 

DB2 update statements for records in the same table

How to expand the tablespace and Field Length in db2

DB2 strings in DB2 Databases

Policy Selection for DB2 environment variable Management

Management tasks that can be completed by the DB2 Management Server

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.