From: | Richard_D_Levine(at)raytheon(dot)com |
---|---|
To: | Scott Marlowe <smarlowe(at)g2switchworks(dot)com> |
Cc: | lorid <lorid(at)dri(dot)edu>, pgsql-sql(at)postgresql(dot)org, pgsql-sql-owner(at)postgresql(dot)org |
Subject: | Re: getting back autonumber just inserted |
Date: | 2005-02-04 14:11:32 |
Message-ID: | OF868C6DCE.09564F53-ON05256F9E.004DB74F@ftw.us.ray.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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.
Thanks,
Rick
Scott Marlowe
<smarlowe(at)g2switchw To: lorid <lorid(at)dri(dot)edu>
orks.com> cc: pgsql-sql(at)postgresql(dot)org
Sent by: Subject: Re: [SQL] getting back autonumber just inserted
pgsql-sql-owner(at)pos
tgresql.org
02/03/2005 05:16 PM
On Thu, 2005-02-03 at 16:16, lorid wrote:
> I could have sworn I kept a copy of prior emails that discussed how to
> get back a value that was just inserted into a autonumber (or in
> postgresql case a sequence number)
If you know the name of the sequence the number came from you can use
currval():
insert into table1 (info) values ('abc');
select currval('table1seq');
Assuming table1seq is the name of the sequence here.
In 8.0 there's a function to do this (I'm not sure of the name, but a
quick search of the 8.0 docs should turn it up.)
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
message can get through to the mailing list cleanly
From | Date | Subject | |
---|---|---|---|
Next Message | q2005 | 2005-02-04 14:13:36 | the best way to get the first record from each group |
Previous Message | Andreas Kretschmer | 2005-02-04 11:34:17 | Re: [despammed] Accessing objects over db-borders |