Re: using sequences

From: Thomas Kellerer <spam_eater(at)gmx(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: using sequences
Date: 2003-06-13 21:03:17
Message-ID: bcde1n$jj4$1@main.gmane.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Erik Price schrieb:
> I have read the manual about sequences and I thought I understood both
> their purpose and how to use them. When I perform inserts, the sequence
> is updated appropriately. However, I can't seem to directly access the
> sequence myself. I always seem to get this message:
>
> 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?
I think the other explenations where pretty good. However there *is* a way
to retrieve the "current value" of sequence regardless whether nextval was
called or not:

SELECT last_value FROM news_news_id_seq;

Regards
Thomas

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ernest E Vogelsinger 2003-06-13 21:04:44 Re: Postgres performance comments from a MySQL user
Previous Message weigelt 2003-06-13 21:00:57 Re: Pg_dumpall