pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Prasanth <lqdcore@bellsouth.net>
To: pgsql-sql@postgresql.org
Subject: Re: Retrieving tuple data on insert
Date: Fri, 8 Aug 2003 16:01:30 -0500
Message-ID: <84UYa.3431$vK4.1253@fe05.atl2.webusenet.com> (raw)
References: <pan.2003.07.24.03.59.01.164717@invalid.mail>

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.






view thread (2+ messages)  latest in thread

Message-ID: <84UYa.3431$vK4.1253@fe05.atl2.webusenet.com>
Permalink:  ../84UYa.3431$vK4.1253@fe05.atl2.webusenet.com/
Also on:    postgresql.org/message-id/84UYa.3431$vK4.1253@fe05.atl2.webusenet.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: lqdcore@bellsouth.net
  Subject: Re: Retrieving tuple data on insert
  In-Reply-To: <84UYa.3431$vK4.1253@fe05.atl2.webusenet.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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