pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Louise Cofield <lcofield@box-works.com>
To: pgsql-interfaces@postgresql.org
Subject: How to insert a string with single quotes in the text
Date: Fri, 19 Sep 2003 15:02:07 -0600
Message-ID: <030701c37ef1$493739c0$7801a8c0@Louise> (raw)

Greetings:

 

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);

 

The insert blows up when it hits an item description that contains a
single quote in the text.  

 

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

 

I appreciate all help!

 

Louise

view thread (3+ messages)  latest in thread

Message-ID: <030701c37ef1$493739c0$7801a8c0@Louise>
Permalink:  ../030701c37ef1$493739c0$7801a8c0@Louise/
Also on:    postgresql.org/message-id/030701c37ef1$493739c0$7801a8c0@Louise

 · 

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: lcofield@box-works.com
  Subject: Re: How to insert a string with single quotes in the text
  In-Reply-To: <030701c37ef1$493739c0$7801a8c0@Louise>

* 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