Re: Retrieving tuple data on insert - Mailing list pgsql-sql

From Prasanth
Subject Re: Retrieving tuple data on insert
Date
Msg-id 84UYa.3431$vK4.1253@fe05.atl2.webusenet.com
Whole thread Raw
List 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.





pgsql-sql by date:

Previous
From: proghome@silesky.com (krystoffff)
Date:
Subject: Error message with a SQL function
Next
From: Tom Lane
Date:
Subject: Re: Error message with a SQL function