Re: How I can read-back a serial value just inserted? - Mailing list pgsql-general

From Adam Rich
Subject Re: How I can read-back a serial value just inserted?
Date
Msg-id 096901c73ac5$9126dcc0$6400a8c0@dualcore
Whole thread Raw
In response to How I can read-back a serial value just inserted?  ("dfx" <dfx@dfx.it>)
Responses Re: How I can read-back a serial value just inserted?
List pgsql-general
If it's a recent PG:

select lastval()

See this:

http://www.postgresql.org/docs/8.2/interactive/functions-sequence.html


-----Original Message-----
From: pgsql-general-owner@postgresql.org
[mailto:pgsql-general-owner@postgresql.org] On Behalf Of dfx
Sent: Monday, January 01, 2007 11:46 AM
To: pgsql-general@postgresql.org
Subject: [GENERAL] How I can read-back a serial value just inserted?


Dear Sirs,

my question is very simple:
when I insert a row whith a serial field, a value is automatically
generated; how  can I know this value, strictly of my row, without the
risk
of to read the value of another subsequent insertion?

Thank you.

Domenico



---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not
       match


pgsql-general by date:

Previous
From: Madison Kelly
Date:
Subject: Re: How I can read-back a serial value just inserted?
Next
From: Gene
Date:
Subject: datatype advice numeric vs. varchar