Re: using sequences

From: weigelt(at)metux(dot)de
To: pgsql-general(at)postgresql(dot)org
Subject: Re: using sequences
Date: 2003-06-13 20:37:08
Message-ID: 20030613203707.GA15208@metux.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Jun 13, 2003 at 04:26:47PM -0400, Erik Price wrote:

<snip>
> be_db=# select currval('news_news_id_seq');
> ERROR: news_news_id_seq.currval is not yet defined in this session
>
> Can someone explain what is going on?
if i understood it right, the sequence values are separate for each
session. so you can easily call currval() w/o having to care what
other sessions do w/ the seq. this of course requires counting up
the seq w/ nextval().

you can get the global status w/ qeuring the sequence relation directly:

SELECT news_news_id_seq.last_value;

cu
--
---------------------------------------------------------------------
Enrico Weigelt == metux ITS
Webhosting ab 5 EUR/Monat. UUCP, rawIP und vieles mehr.

phone: +49 36207 519931 www: http://www.metux.de/
fax: +49 36207 519932 email: contact(at)metux(dot)de
cellphone: +49 174 7066481 smsgate: sms(dot)weigelt(at)metux(dot)de
---------------------------------------------------------------------
Diese Mail wurde mit UUCP versandt. http://www.metux.de/uucp/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2003-06-13 20:38:07 Re: Query planner question
Previous Message Dann Corbit 2003-06-13 20:36:46 Re: return records in DB load order??