Re: getting currval from a sequence - BUG ?

From: Darren Ferguson <darren(at)crystalballinc(dot)com>
To: Jan Poslusny <pajout(at)gingerall(dot)cz>
Cc: tony <tony(at)animaproductions(dot)com>, postgres list <pgsql-general(at)postgresql(dot)org>
Subject: Re: getting currval from a sequence - BUG ?
Date: 2002-02-11 18:30:31
Message-ID: Pine.LNX.4.10.10202111329250.18611-100000@thread.crystalballinc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

You are right with the currval but it is not a bug since you have not
initiated a nextval in the current session yet.

Check the list 3 - 4weeks back there was a nice thread about this and it
should hoepfully provide the answer

Darren

On Mon, 11 Feb 2002, Jan Poslusny wrote:

> Hi,
> select currval('sequence_name');
> with quotes should help you. But my pg 7.1.2 throws error
> "sequence_name.currval is not yet defined in this session" (possibly bug
> ?). If I use sequence before calling this (for instance "insert into
> mytable values(nextval('sequence_name'));" ), all is OK.
>
> pajout
>
>
> Bruno Wolff III wrote:
>
> > On Mon, Feb 11, 2002 at 11:42:31AM +0100,
> > tony <tony(at)animaproductions(dot)com> wrote:
> >
> >>How does one get the last record from a series of records? I just need
> >>the id field which is a sequence field
> >>
> >
> > select max(id) from whatever;
> > (This assumes the sequence hasn't rolled over.)
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 2: you can get off all lists at once with the unregister command
> > (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
> >
> >
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Doug McNaught 2002-02-11 18:49:56 Re: compiling on sco
Previous Message jtp 2002-02-11 18:13:21 compiling on sco