Home » SQL & PL/SQL » SQL & PL/SQL » replace single apostrophe with 2 apostrophes in a single sql statement
replace single apostrophe with 2 apostrophes in a single sql statement [message #9005] Fri, 10 October 2003 11:02 Go to next message
Hugh
Messages: 7
Registered: April 2002
Junior Member
Hi,

I want to replace all single apostrophes with 2 of the for a column in a table.

I know the syntax is something like
update peiscompany SET co_name = translate(co_name,'s','d');

where s is a single apostrophe and d would be 2 single apostrophes however I can't get it right.

I've tried the following but with no luck

update peiscompany SET co_name = translate(co_name,chr(39),chr(39)||chr(39));

Can someone help me?

Cheers
Re: replace single apostrophe with 2 apostrophes in a single sql statement [message #9007 is a reply to message #9005] Fri, 10 October 2003 11:52 Go to previous message
Thiru
Messages: 1089
Registered: May 2002
Senior Member
thiru@9.2.0:SQL>select * from t;

NAME
------------------------------
'
thiru@9.2.0:SQL>update t set name=replace(name,'''','''''') ;

1 row updated.

thiru@9.2.0:SQL>select * from t;

NAME
------------------------------
''
Previous Topic: Date Calculation
Next Topic: dbms_profiler
Goto Forum:
  


Current Time: Fri Mar 29 06:13:30 CDT 2024