How to handle Single Quotes in Pl/SQL?

Reply

Join Date: Dec 2008
Posts: 9
Reputation: like_to_learn is an unknown quantity at this point 
Solved Threads: 0
like_to_learn's Avatar
like_to_learn like_to_learn is offline Offline
Newbie Poster

How to handle Single Quotes in Pl/SQL?

 
0
  #1
Dec 9th, 2008
hai,

My requirement is given below.
In my application one LOV is there to show Insured names.In that if we query for the name like ahemd's% then it is showing wrong(junk) data..................So,my question is how to add single quote to already existing single quote.........................I tried in many ways but I didn't get any solutions for this...............even I used Q'[]' frunction but no use.................................One more thing,we need to query for that name dynamically means.............

select '&name' from dual;
where '&name' -- you can pass as ahemd's..................but once you give this you will get a eror message like
"ORA-01756: quoted string not properly terminated".please send me solution..........................
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 2,104
Reputation: debasisdas will become famous soon enough debasisdas will become famous soon enough 
Solved Threads: 128
debasisdas's Avatar
debasisdas debasisdas is offline Offline
Postaholic

Re: How to handle Single Quotes in Pl/SQL?

 
0
  #2
Dec 9th, 2008
you need to use REPLACE function to work around single quote.
Share your Knowledge.
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 9
Reputation: like_to_learn is an unknown quantity at this point 
Solved Threads: 0
like_to_learn's Avatar
like_to_learn like_to_learn is offline Offline
Newbie Poster

Re: How to handle Single Quotes in Pl/SQL?

 
0
  #3
Dec 10th, 2008
How can I use Replace function?
I am passing the sting dynamically..............
ex:
SELECT REPLACE('&NAME',''',''''') FROM DUAL; if you run this statement,it will ask the name
then you just enter adem's.....
If you execute that statement you will get
"ORA-01756: quoted string not properly terminated" error..........
please suggest me, is there any way to handle.................
Last edited by peter_budo; Dec 12th, 2008 at 7:09 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 1
Reputation: irukulapati is an unknown quantity at this point 
Solved Threads: 0
irukulapati irukulapati is offline Offline
Newbie Poster

Re: How to handle Single Quotes in Pl/SQL?

 
0
  #4
Sep 16th, 2009
I don't think you are still looking for this answer.But I thought I would post answer so that it would be helpful who are following this thread.

assuming that you are trying to eliminate single quote.

  1. SELECT REPLACE('&NAME','''','') FROM DUAL

pass 2 singlequotes in the parameter for adem's

ex:adem''s

would return adems

OR
from the given table

  1. SELECT REPLACE(col1,'''','') FROM TEMP
  2. WHERE col1='adem''s'

The actual data in the column reads as adem's
Last edited by peter_budo; Sep 22nd, 2009 at 9:24 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reply With Quote Quick reply to this message  
Reply

Message:



Similar Threads
Other Threads in the Oracle Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC