| From: | Theodore Petrosky <tedpet5(at)yahoo(dot)com> |
|---|---|
| To: | mail TechEvolution <mail(at)techevolution(dot)be> |
| Cc: | pgsql-sql(at)postgresql(dot)org |
| Subject: | Re: getting back autonumber just inserted |
| Date: | 2005-07-07 20:14:33 |
| Message-ID: | 20050707201433.94901.qmail@web41013.mail.yahoo.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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(at)techevolution(dot)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/
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Scott Marlowe | 2005-07-07 20:21:49 | Re: getting back autonumber just inserted |
| Previous Message | Alvaro Herrera | 2005-07-07 19:15:10 | Re: getting back autonumber just inserted |