Implementation method of string concatenation in Oracle _oracle

Source: Internet
Author: User
Similar to other database systems, Oracle string concatenation uses the "| |" string concatenation, which is used in the same way as the plus sign "+" in MSSQLServer.

For example, execute the following SQL statement:

Copy Code code as follows:

SELECT ' work # for ' | | fnumber| | ' The employee's 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 (' Work No.: ', Fnumber) from T_employee

If the value of the connection in Concat is not a string, Oracle attempts to convert it to a string, such as executing the following SQL statement:
SELECT CONCAT (' Age: ', Fage) from T_employee

Unlike the MySQL concat () function, Oracle's CONCAT () function supports only two parameters and does not support stitching of more than two strings, for example, the following SQL statement is incorrect in Oracle:
SELECT CONCAT (' Work number is ', Fnumber, ' Employee name is ', FName ') from T_employee
WHERE FName is not NULL
Oracle will report the following error message after running:
Invalid number of arguments

If you want to stitch multiple strings, you can use multiple concat () functions that can be nested using the following SQL to overwrite:

Copy Code code as follows:

SELECT CONCAT (CONCAT CONCAT (' Work number ', Fnumber), ' Employee Name '), 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.