X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3523F476022 for ; Sun, 11 May 2003 00:40:17 -0400 (EDT) Received: from wolff.to (wolff.to [66.93.249.74]) by postgresql.org (Postfix) with SMTP id 315F14758F1 for ; Sun, 11 May 2003 00:39:43 -0400 (EDT) Received: (qmail 20205 invoked by uid 500); 11 May 2003 04:41:04 -0000 Date: Sat, 10 May 2003 23:41:04 -0500 From: Bruno Wolff III To: Matthew Horoschun Cc: pgsql-sql@postgresql.org Subject: Re: Knowing when it is safe to call currval() Message-ID: <20030511044104.GA20184@wolff.to> Mail-Followup-To: Matthew Horoschun , pgsql-sql@postgresql.org References: <9377CBC6-8366-11D7-B0B7-000393B3A702@canprint.com.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9377CBC6-8366-11D7-B0B7-000393B3A702@canprint.com.au> User-Agent: Mutt/1.5.4i X-Spam-Status: No, hits=-28.8 required=5.0 tests=BAYES_20,IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200305/203 X-Sequence-Number: 13368 On Sun, May 11, 2003 at 14:11:01 +1000, Matthew Horoschun 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?