Re: getting back autonumber just inserted - Mailing list pgsql-sql

From Theodore Petrosky
Subject Re: getting back autonumber just inserted
Date
Msg-id 20050707201433.94901.qmail@web41013.mail.yahoo.com
Whole thread Raw
In response to getting back autonumber just inserted  (mail TechEvolution <mail@techevolution.be>)
Responses Re: getting back autonumber just inserted
Re: getting back autonumber just inserted
Re: getting back autonumber just inserted
List pgsql-sql
you have to use currval inside a transaction...

begin;
insert something that increments the counter;
select currval('sequence_name');
end;

using currval inside a transaction guarantees that the
value is correct for your insert statement and has not
changed by another insert statement.

Ted


--- mail TechEvolution <mail@techevolution.be> wrote:

> hello
> 
> i ame a newbie to PostGreSQL, I ame using PostGreSQL
> 8.0 
> (windowsinstaller) on a xp prof platform
> 
> i would like to get back the autonumber from the
> last record inserted, 
> for other SQL db (m$ sql db ...) i could use:
> SELECT @@ IDENTITY
> 
> can someone help me by informing me what the SQL
> syntax is to be used 
> with PostGreSQL db and get the same result, the last
> autonumber inserted?
> 
> greeTz
> 
> wes
> 
> ---------------------------(end of
> broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
> 


    
____________________________________________________
Sell on Yahoo! Auctions – no fees. Bid on great items.  
http://auctions.yahoo.com/


pgsql-sql by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: getting back autonumber just inserted
Next
From: Scott Marlowe
Date:
Subject: Re: getting back autonumber just inserted