pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Re: Retrieving tuple data on insert
2+ messages / 2 participants
[nested] [flat]

* Re: Retrieving tuple data on insert
@ 2003-08-08 21:01 Prasanth <lqdcore@bellsouth.net>
  2003-08-10 03:13 ` Re: Retrieving tuple data on insert sebmil <sebmil@invalid.mail>
  0 siblings, 1 reply; 2+ messages in thread

From: Prasanth @ 2003-08-08 21:01 UTC (permalink / raw)
  To: pgsql-sql

you can retrieve it using the currentVal function on the
sequence used to generate that id.


"sebmil" <sebmil@invalid.mail> wrote in message
news:pan.2003.07.24.03.59.01.164717@invalid.mail...
> Hello,
>
> I have a table with two columns, created with : CREATE TABLE test ( id
> serial primary key, name text ) ;
>
> To populate the table i use :
> INSERT INTO test(name) values('test1'); so the "id" is automatically set
> by PostgreSQL.
>
> Now the problem, i would like to retrieve the value of "id" that
> PostgreSQL assigns to this tuple, but i can't make a SELECT on the name i
> just inserted because it's not UNIQUE, so SELECT may return multiple
> results.
>
> Is there a way to retrieve the value of "id" from the insertion ?
>
> I was thinking of something with Oids, like getting the Oid of the INSERT
> statement then use it to SELECT the tuple, but i didn't find what to do
> with an Oid in PostgreSQL documentation.
>
> Also, it would be better if it was possible in only one operation (not
> INSERT then SELECT).
>
> Thanks in advance.






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

* Re: Retrieving tuple data on insert
  2003-08-08 21:01 Re: Retrieving tuple data on insert Prasanth <lqdcore@bellsouth.net>
@ 2003-08-10 03:13 ` sebmil <sebmil@invalid.mail>
  0 siblings, 0 replies; 2+ messages in thread

From: sebmil @ 2003-08-10 03:13 UTC (permalink / raw)
  To: pgsql-sql

> you can retrieve it using the currentVal function on the sequence used to
> generate that id.

Thank you.




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


end of thread, other threads:[~2003-08-10 03:13 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-08-08 21:01 Re: Retrieving tuple data on insert Prasanth <lqdcore@bellsouth.net>
2003-08-10 03:13 ` sebmil <sebmil@invalid.mail>

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