Solved

how to replace '&' and '()' in sql query for oracle using regex

Posted on 2016-11-21
8
41 Views
Last Modified: 2016-11-24
Hi,
I have columns in my database which have & and () .I want to replace '&' with word 'and' '()' with word 'bracket'
is it possible to do in oracle using regex?

Eg. String: This is a test & temp ()

output like : This is a test and temp bracket.

thnks in advance.
0
Comment
Question by:Pank Gurav
8 Comments
 
LVL 17

Accepted Solution

by:
Pawan Kumar Khowal earned 500 total points
ID: 41896978
Try

WITH CTE AS
(
    
    SELECT 'This is a test & temp ()' a FROM DUAL
    
)
SELECT A , REPLACE(REPLACE(A,'&','AND'),'()','bracket') a1 FROM CTE

Open in new window


Output

 	A	                                        A1          
1	This is a test & temp ()  	This is a test AND temp bracket

Open in new window

0
 

Author Comment

by:Pank Gurav
ID: 41896980
Hi,
I am trying this query in SQL developer, but the answer is not correct .
0
 
LVL 17

Expert Comment

by:Pawan Kumar Khowal
ID: 41896981
What query you r trying?
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 17

Expert Comment

by:Pawan Kumar Khowal
ID: 41897264
Hi Pank Gurav,
Could you please update if this is done or not?

Regards,
Pawan
0
 
LVL 22

Expert Comment

by:Helena Marková
ID: 41897383
It works for me - SQL Navigator, Oracle 11g
EE.PNG
0
 
LVL 31

Expert Comment

by:awking00
ID: 41897478
>>I am trying this query in SQL developer, but the answer is not correct<<
Please show the query and the incorrect answer.
0
 
LVL 31

Expert Comment

by:awking00
ID: 41897945
It may be that Oracle is interpreting the ampersand for defining a substitution variable . Try running the query after issuing the following command:
set define off
1

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now