Solved

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

Posted on 2016-11-21
8
145 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 29

Accepted Solution

by:
Pawan Kumar 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 29

Expert Comment

by:Pawan Kumar
ID: 41896981
What query you r trying?
0
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
LVL 29

Expert Comment

by:Pawan Kumar
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 32

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 32

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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This video shows how to recover a database from a user managed backup
Suggested Courses

624 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