Re: Knowing when it is safe to call currval() - Mailing list pgsql-sql

From Bruno Wolff III
Subject Re: Knowing when it is safe to call currval()
Date
Msg-id 20030511044104.GA20184@wolff.to
Whole thread Raw
In response to Knowing when it is safe to call currval()  (Matthew Horoschun <mhoroschun@canprint.com.au>)
List pgsql-sql
On Sun, May 11, 2003 at 14:11:01 +1000, Matthew Horoschun <mhoroschun@canprint.com.au> wrote:
> Hi All,
> 
> Is there any way to know ahead of time whether calling currval() on a 
> sequence will cause an exception like:
> 
> ERROR:  some_id_seq.currval is not yet defined in this session
> 
> In my function I can't be sure whether nextval() will have previously 
> been called in the session.

Well you could just call nextval at the start of the session to make sure
it has a value.

Howvere it is odd that you would want to call currval when there may not
have already been a call to nextval. What are you doing with the returned
value?



pgsql-sql by date:

Previous
From: Matthew Horoschun
Date:
Subject: Knowing when it is safe to call currval()
Next
From: Bruno Wolff III
Date:
Subject: Re: Knowing when it is safe to call currval()