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 2D935D1B550 for ; Sat, 20 Sep 2003 17:32:32 +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 40693-09 for ; Sat, 20 Sep 2003 14:32:00 -0300 (ADT) Received: from wolff.to (wolff.to [66.93.249.74]) by svr1.postgresql.org (Postfix) with SMTP id 836B5D1B54C for ; Sat, 20 Sep 2003 14:31:59 -0300 (ADT) Received: (qmail 18071 invoked by uid 500); 20 Sep 2003 17:38:48 -0000 Date: Sat, 20 Sep 2003 12:38:47 -0500 From: Bruno Wolff III To: Louise Cofield Cc: pgsql-interfaces@postgresql.org Subject: Re: How to insert a string with single quotes in the text Message-ID: <20030920173847.GA17807@wolff.to> Mail-Followup-To: Louise Cofield , pgsql-interfaces@postgresql.org References: <030701c37ef1$493739c0$7801a8c0@Louise> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <030701c37ef1$493739c0$7801a8c0@Louise> User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200309/51 X-Sequence-Number: 4469 On Fri, Sep 19, 2003 at 15:02:07 -0600, Louise Cofield 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.