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

From Magnus Hagander
Subject Re: getting back autonumber just inserted
Date
Msg-id 6BCB9D8A16AC4241919521715F4D8BCE4767C5@algol.sollentuna.se
Whole thread Raw
In response to getting back autonumber just inserted  (lorid <lorid@dri.edu>)
List pgsql-sql
> I don't work with M$ DBs, but saw that "autonumber" is an M$ concept.
> Purely for my own edification, how do you get the most resent
> value of an autonumber in M$?  I was helping someone out who
> was using M$ stuff and was amazed that there was no currval function.

I beleive they call it IDENTITY and not autonumber.
You get it using either
SELECT @@IDENTITY
or
SELECT SCOPE_IDENTITY()

depending on if you want the very latest identity or the latest int he
current scope (if you have a trigger inserting records in a different
table, they will differ - @@IDENTITY will return from the table affected
by the trigger, SCOPE_IDENTITY() will return it for the table *you*
updated)

//Magnus


pgsql-sql by date:

Previous
From: Richard_D_Levine@raytheon.com
Date:
Subject: Re: getting back autonumber just inserted
Next
From: Don Drake
Date:
Subject: Re: Determining Rank