From: | "Jackson, DeJuan" <djackson(at)cpsgroup(dot)com> |
---|---|
To: | James Oden <joden(at)lee(dot)k12(dot)nc(dot)us>, dustin sallings <dustin(at)spy(dot)net>, Fran Fabrizio <fran(at)primary(dot)net> |
Cc: | pgsql-general(at)postgreSQL(dot)org |
Subject: | RE: [GENERAL] getting the currval of a sequence |
Date: | 1998-08-14 14:39:12 |
Message-ID: | F10BB1FAF801D111829B0060971D839F399523@cpsmail |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
> >On Fri, 14 Aug 1998, Fran Fabrizio wrote:
> >
> > If you've recently done an insert and want to know what the value
> >was, you can do this:
> >
> > select last_value from mysequence;
>
> Alternatively, you can get your key from the sequence before you
> insert, and
> override the default value of the key (they will be the same only now
> you
> explicitly got it). Now that you know what the key value use, after
> you
> insert it you can do anything you want to with it. To do this just
> do:
>
> select nextval ('sequencename');
>
> ...james
I think you should just go with what Vadim suggested and use:
select currval('my_sequence');
This will be the same within a transaction, even if there is another
transaction using the same sequence.
But (if memory servers), you have to have had select a nextval from that
same sequence within the transaction.
Hope this clears things up.
-DEJ
From | Date | Subject | |
---|---|---|---|
Next Message | James Olin Oden | 1998-08-14 14:48:19 | Re: [GENERAL] getting the currval of a sequence |
Previous Message | 윤영철 | 1998-08-14 13:36:29 |