pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruno Wolff III <bruno@wolff.to>
To: Louise Cofield <lcofield@box-works.com>
Cc: pgsql-interfaces@postgresql.org
Subject: Re: How to insert a string with single quotes in the text
Date: Sat, 20 Sep 2003 12:38:47 -0500
Message-ID: <20030920173847.GA17807@wolff.to> (raw)
In-Reply-To: <030701c37ef1$493739c0$7801a8c0@Louise>
References: <030701c37ef1$493739c0$7801a8c0@Louise>

On Fri, Sep 19, 2003 at 15:02:07 -0600,
  Louise Cofield <lcofield@box-works.com> wrote:
> 
> I am creating a Libpq program that reads a text file, and inserts values
> into a Postgres table.  An example of my insert statement looks like
> this:
> 
> SPRINTF(str, "INSERT INTO itm_table (itm_num, itm_desc) values ('%s',
> '%s');", sitmnum, sitmdesc);
> 
> Other than stripping the offending quote-marks from  the text prior to
> processing, does anybody have any ideas how I can deal with this?

Scan the input and put backslashes in front of backslashes and single quotes.



view thread (3+ messages)

Message-ID: <20030920173847.GA17807@wolff.to>
Permalink:  ../20030920173847.GA17807@wolff.to/
Also on:    postgresql.org/message-id/20030920173847.GA17807@wolff.to

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: bruno@wolff.to, lcofield@box-works.com
  Subject: Re: How to insert a string with single quotes in the text
  In-Reply-To: <20030920173847.GA17807@wolff.to>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox