X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 3226DD1B555 for ; Fri, 19 Sep 2003 21:02:53 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 51494-05 for ; Fri, 19 Sep 2003 18:02:23 -0300 (ADT) Received: from ns.lanterm.net (unknown [208.187.178.11]) by svr1.postgresql.org (Postfix) with ESMTP id B1B89D1B535 for ; Fri, 19 Sep 2003 18:02:05 -0300 (ADT) Received: from Louise ([208.187.178.2]) by ns.lanterm.net (8.11.6/8.11.6) with ESMTP id h8JK1Fs12073 for ; Fri, 19 Sep 2003 14:01:15 -0600 From: "Louise Cofield" To: 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> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0308_01C37EBE.FE9CC9C0" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.3416 Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=HTML_60_70 X-Spam-Level: X-Archive-Number: 200309/45 X-Sequence-Number: 4463 This is a multi-part message in MIME format. ------=_NextPart_000_0308_01C37EBE.FE9CC9C0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 ------=_NextPart_000_0308_01C37EBE.FE9CC9C0 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Greetings:

 

I am creating a Libpq program that reads a text file, and inserts values into a Postgres table.  An example of my insert stateme= nt 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 &nbs= p;the text prior to processing, does anybody have any ideas how I can deal with t= his?

 

I appreciate all help!

 

Louise

------=_NextPart_000_0308_01C37EBE.FE9CC9C0--