Re: Knowing when it is safe to call currval()

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Matthew Horoschun <mhoroschun(at)canprint(dot)com(dot)au>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Knowing when it is safe to call currval()
Date: 2003-05-11 04:41:04
Message-ID: 20030511044104.GA20184@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Sun, May 11, 2003 at 14:11:01 +1000,
Matthew Horoschun <mhoroschun(at)canprint(dot)com(dot)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?

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Bruno Wolff III 2003-05-11 13:35:13 Re: Knowing when it is safe to call currval()
Previous Message Matthew Horoschun 2003-05-11 04:11:01 Knowing when it is safe to call currval()