Re: working with sequences

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alex Ott <ott(at)jet(dot)msk(dot)su>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: working with sequences
Date: 2002-01-31 16:57:44
Message-ID: 3228.1012496264@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Alex Ott <ott(at)jet(dot)msk(dot)su> writes:
> and after insert i need get current value of sequence
> 'rfc822_address_seq'. I do this with
> select currval('rfc822_addr_spec_seq')
> but sometimes this query return none and my programm crash. This offten
> happen after 2-3 call of nextval

This is quite hard to believe; if currval() has succeeded once then
I don't see how it could fail later on in the same session.

Are you sure you are passing the same sequence name each time?
currval will fail if asked about a sequence name that hasn't
been nextval'd earlier in the current session.

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Annie Bai 2002-01-31 19:33:36 Re: How to merge several attributes and Delete an attribute
Previous Message Tom Lane 2002-01-31 16:47:49 Re: [SQL] Regression tests failed on 7.2rc2