PQescapeString

From: Mark Thomas <thomas(at)pbegames(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: PQescapeString
Date: 2002-06-07 18:27:44
Message-ID: 5.1.0.14.2.20020607141636.00ac87f0@pbegames.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

I'm using postgresql via libpq for a web based application.

PQescapeString works as advertized, escaping special characters out of
strings so they can be included in queries. However once I've inserted the
escaped string into the database, there doesn't seem to be a reverse
process to unescape the string. Is there a straightforward way to do it?

For example I retrieve the following string from a web form:

"This is a test of postgresql's escaping mechanism"

Running it through PQescapeString produces:

"This is a test of postgresql''s escaping mechanism"

And I end up with a query string that looks like:

INSERT INTO "some_table" (ttext)
VALUES ('This is a test of postgresql''s escaping mechanism')

Subsequently I do:

SELECT ttext from "some_table";

This is a test of postgresql''s escaping mechanism

Obviously I need to process this string to remove the escaping ' (and
likely turn \\ into \ as well as other translations), but I don't see any
mechanism to do it.

Mark Thomas
---
thomas(at)pbegames(dot)com ----> http://www.pbegames.com/~thomas
Play by Electron Games -> http://www.pbegames.com Free Trial Games

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message John Gray 2002-06-07 19:36:27 Re: HELP! Cannot access table!!!!
Previous Message von Schwerdtner, Thomas (GXS, FPI) 2002-06-07 16:21:47 Conditional Join (or something along those lines)