Implementation of string connection in Oracle

Source: Internet
Author: User

Similar to other database systems, Oracle uses "|" to concatenate strings, which is the same as the plus sign "+" in MSSQLServer.

For example, execute the following SQL statement:

Copy codeThe Code is as follows: SELECT 'employee ID is '| FNumber |' employee name is '| FName FROM T_Employee
WHERE FName IS NOT NULL

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

If the connected value in CONCAT is not a string, Oracle will try to convert it to a string, such as executing the following SQL statement:
Select concat ('Age: ', FAge) FROM T_Employee

Unlike MYSQL's CONCAT () function, Oracle'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:
Invalid Number of parameters

To splice multiple strings, you can use multiple CONCAT () functions for nesting. The preceding SQL statement can be rewritten as follows:

Copy codeThe Code is as follows: select concat ('employee ID is ', FNumber),' employee name is '), FName) FROM
T_Employee
WHERE 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.