Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id A61D8650402 for ; Wed, 27 Aug 2008 21:54:10 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 39485-01-6 for ; Wed, 27 Aug 2008 21:53:58 -0300 (ADT) X-Greylist: delayed 00:57:19.253855 by SQLgrey-1.7.6 Received: from smtp1.pcisys.net (smtp1.pcisys.net [216.229.32.113]) by postgresql.org (Postfix) with ESMTP id 8CA6D64FF8E for ; Wed, 27 Aug 2008 21:29:26 -0300 (ADT) Received: from [192.168.8.17] (70-58-171-92.clsp.qwest.net [70.58.171.92]) (authenticated bits=0) by smtp1.pcisys.net (8.13.6/8.13.6) with ESMTP id m7RNW0jF014753 for ; Wed, 27 Aug 2008 17:32:06 -0600 (MDT) User-Agent: Microsoft-Entourage/12.12.0.080729 Date: Wed, 27 Aug 2008 17:31:57 -0600 Subject: Re: FW: Libpq and the SQL RETURNING clause From: Keary Suska To: Postgres-Interfaces Message-ID: Thread-Topic: [INTERFACES] FW: Libpq and the SQL RETURNING clause Thread-Index: AckHeQiCaBeMR5FJQrKjwewrES+tvgA2BqmwABL9U7M= In-Reply-To: Mime-version: 1.0 Content-type: text/plain; charset="US-ASCII" Content-transfer-encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200808/23 X-Sequence-Number: 6798 8/27/08 8:28 AM, also sprach Georges.Brefort@sanofi-aventis.com: > > > ________________________________ > > From: Brefort, Georges R&D/FR > Sent: Tuesday, August 26, 2008 2:41 PM > To: pgsql-interfaces@postgresql.org > Subject: Libpq and the SQL RETURNING clause > > > Dear Postgres specialist, > > 1 Assume you have a table such as the following: > > CREATE TABLE example( id SERIAL, someData VARCHAR(32) ); > > 2 Now, you use a SQL statement to insert the data and get the the id > value back: > > INSERT INTO example( someData ) VALUES( 'BlaBlaBla' ) RETURNING id; > > I wonder if it is possible to retrieve the value of the id field in an > application using the C libpq library. Yes. I do it all the time. Simply treat the result as if it was from a select statement. HTH, Keary Suska Esoteritech, Inc. "Demystifying technology for your home or business"