Oracle Database String Connection method

Source: Internet
Author: User

Go to: http://database.51cto.com/art/201011/232267.htm

Similar to other database systems, Oracle string connections use the "| |" string concatenation, which is used in 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 "| |", Oracle supports string concatenation using the concat () function, such as executing the following SQL statement:
SELECT CONCAT (' Work number: ', fnumber) from T_employee

If the value connected 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 MySQL's concat () function, Oracle's CONCAT () function supports only two parameters and does not support stitching of more than two strings, such as the following SQL statement that 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:
Invalid number of arguments

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

SQL change common query statement:

1.select Lower (Sys_guid ()) from dual; generating UUID

2.select ' INSERT into SSJ values (' | | Lower (Sys_guid ()) | | ', ' | | mmi.mmi_medical_mechanism_name| | '); ' from Js_medical_mechanism_info MMI; generating INSERT statements

Oracle Database String Connection method

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.