Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: replace ' with '' ???
Janet,
Sorry, I'm just going through the list. I've run into the same problem. Have you got any answers? I got it resolved by using the following code that I found but I don't remember where/who I found it from. Something like this:
String FChar =
request.getParameter("p_location_name").toUpperCase().trim();
StringBuffer lsNewStr = new StringBuffer(); int liFound = 0; int liLastPointer=0; do { liFound = FChar.indexOf('\'', liLastPointer); if ( liFound < 0 ) lsNewStr.append(FChar.substring(liLastPointer, FChar.length())); else { if (liFound > liLastPointer) lsNewStr.append(FChar.substring(liLastPointer,liFound)); lsNewStr.append('\''); lsNewStr.append('\''); liLastPointer = liFound + 1; } }while (liFound > -1); FChar = lsNewStr.toString();
Perhap you have received better answers than this that you could share with me.
Thanks,
Jeff Eberhard
Database Administrator
Rolls-Royce Gear Systems
-----Original Message-----
Sent: Tuesday, September 16, 2003 1:45 PM
To: Multiple recipients of list ORACLE-L
Hi,
I apologize it might be a wrong place to post the question, but since it's the only list I know ...
You know when you insert a'b into db, you got to
change it to a''b, our value is from jsp, so I have
this
request.getParameter("p_location_name").toUpperCase().trim(),
in case there is ' in it, I need to replace it with
''. How to do this in jsp, I tried
string.replace('\'','\'\''), replace("'","''"),
replace("\'","\'\'"), all sorts stuff and doesn't
work. We are using jdk 1.3.1. Any suggestion??
Thank you!
Janet
Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services ---------------------------------------------------------------------To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services ---------------------------------------------------------------------To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). Received on Fri Sep 19 2003 - 12:39:40 CDT