Re: Escaping strings?

From: "Paul Stead" <pstead(at)elementallogic(dot)com>
To: <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Escaping strings?
Date: 2002-11-04 04:06:55
Message-ID: BNENLMOEFCOIEGKDJMLLGEGCCDAA.pstead@elementallogic.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Just curious....

Does Oracle accept escaping a ' with \'
Or do you have to escape a ' with '' in Oracle?

Paul

-----Original Message-----
From: pgsql-jdbc-owner(at)postgresql(dot)org
[mailto:pgsql-jdbc-owner(at)postgresql(dot)org]On Behalf Of Thomas O'Dowd
Sent: Sunday, November 03, 2002 7:32 PM
To: Chris White
Cc: Timothy Reaves; pgsql-jdbc(at)postgresql(dot)org
Subject: Re: [JDBC] Escaping strings?

Hmmm... I had no idea :) Actually, I just had a look at the driver code
behind setString(). It actually looks pretty similar to what I wrote
earlier and doesn't escape the '_' as far as I can see.

synchronized (sbuf)
{
sbuf.setLength(0);
sbuf.ensureCapacity(x.length());
int i;

sbuf.append('\'');
for (i = 0 ; i < x.length() ; ++i)
{
char c = x.charAt(i);
if (c == '\\' || c == '\'')
sbuf.append((char)'\\');
sbuf.append(c);
}
sbuf.append('\'');
bind(parameterIndex, sbuf.toString(), type);
}

Does the '_' need to be escaped? Why? If so, the driver code should be
updated I guess.

Tom.

On Mon, 2002-11-04 at 12:10, Chris White wrote:
> I think you also have to escape underscore(_).

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Dave Cramer 2002-11-04 04:11:50 Re: Question arising from a post
Previous Message Dave Cramer 2002-11-04 04:04:51 Re: [Solved] A result was returned by the statement, when