pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
FW: Libpq and the SQL RETURNING clause
2+ messages / 2 participants
[nested] [flat]

* FW: Libpq and the SQL RETURNING clause
@ 2008-08-27 14:28  Georges.Brefort@sanofi-aventis.com
  0 siblings, 1 reply; 2+ messages in thread

From: Georges.Brefort@sanofi-aventis.com @ 2008-08-27 14:28 UTC (permalink / raw)
  To: pgsql-interfaces

 

________________________________

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. 
 
I pretty much understand how to bind data with the libpq, or how to
retrieve result sets from a SELECT SQL statement, but not how to
retrieve data from that RETURNING clause. (I have many years of practice
of the RETURNING clause in the ORACLE C library, but that is not the
point here).
 
Thank you very much for your help and your patience.
With my best regards.
 
Georges BREFORT

^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: FW: Libpq and the SQL RETURNING clause
@ 2008-08-27 23:31  Keary Suska <hierophant@pcisys.net>
  parent: Georges.Brefort@sanofi-aventis.com
  0 siblings, 0 replies; 2+ messages in thread

From: Keary Suska @ 2008-08-27 23:31 UTC (permalink / raw)
  To: pgsql-interfaces

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"





^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2008-08-27 23:31 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2008-08-27 14:28 FW: Libpq and the SQL RETURNING clause Georges.Brefort@sanofi-aventis.com
2008-08-27 23:31 ` Keary Suska <hierophant@pcisys.net>

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