DB2 string connection

Source: Internet
Author: User

The DB2 string connection is the same as that of the oracle database. "|" is used for the DB2 string connection. It is used in the same way as the plus sign "+" in MSSQLServer. For example, execute the following SQL statement: SELECT 'employee ID IS '| FNumber |' employee name IS '| FName FROM T_EmployeeWHERE FName IS NOT NULL www.2cto.com except "| ", DB2 also supports String concatenation using the CONCAT () function. For example, execute the following SQL statement: SELECT CONCAT ('employee: ', FNumber) FROM T_Employee is different FROM 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) after running FROM T_Employee, DB2 will report the following error message: the authorized instance with compatible independent variables and mysql concat () whose type is "FUNCTION" and named "CONCAT" is not found () different functions, the CONCAT () function of DB2 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_EmployeeWHERE FName is not null after running Oracle will report the following error message: authorization routines whose type is "FUNCTION" named "CONCAT" and compatible with independent variables cannot be found. To splice multiple strings, you can use multiple CONCAT () for nested functions, the preceding SQL statement can be rewritten as follows: SELECT CONCAT ('employee ID ', FNumber), 'employee name'), FName) FROMT_EmployeeWHERE FName IS NOT NULL

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.