Re: How to insert a string with single quotes in the

From: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
To: Louise Cofield <lcofield(at)box-works(dot)com>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: How to insert a string with single quotes in the
Date: 2003-09-20 17:24:08
Message-ID: 1064078648.5362.559.camel@linda.lfix.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

On Fri, 2003-09-19 at 22:02, Louise Cofield wrote:
> I am creating a Libpq program that reads a text file,
...
> The insert blows up when it hits an item description that contains a
> single quote in the text.

You also have to look out for backslashes.

> Other than stripping the offending quote-marks from the text prior to
> processing, does anybody have any ideas how I can deal with this?

The libpq library includes the function PQescapeString, as described in
the manual.

--
Oliver Elphick Oliver(dot)Elphick(at)lfix(dot)co(dot)uk
Isle of Wight, UK http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C
========================================
"But my God shall supply all your need according to his
riches in glory by Christ Jesus." Philippians 4:19

In response to

Browse pgsql-interfaces by date

  From Date Subject
Next Message Bruno Wolff III 2003-09-20 17:38:47 Re: How to insert a string with single quotes in the text
Previous Message Mayank Goyal 2003-09-20 13:58:22 Need information for C++ interface