Re: calling currval() before nextval() patch adding - Mailing list pgsql-patches

From John Hansen
Subject Re: calling currval() before nextval() patch adding
Date
Msg-id 1099872623.16869.36.camel@localhost.localdomain
Whole thread Raw
In response to Re: calling currval() before nextval() patch adding  (Rod Taylor <pg@rbt.ca>)
List pgsql-patches
> This might do what you're looking for on 8.0.
>
> CREATE OR REPLACE FUNCTION currval_isset(text) RETURNS bigint AS '
> DECLARE
>   var integer;
> BEGIN
>   SELECT currval($1) INTO var;
>
>   RETURN var;
>
> EXCEPTION
>   WHEN     OBJECT_NOT_IN_PREREQUISITE_STATE THEN
>     RETURN 0;
> END;
> ' LANGUAGE plpgsql;
>
> SELECT isset('tst_seq');
>

k, i don't actually have an 8.0 installation to play with here,. but
won't this still produce a warning?


pgsql-patches by date:

Previous
From: Tom Lane
Date:
Subject: Re: calling currval() before nextval() patch adding currval_isset()
Next
From: John Hansen
Date:
Subject: Re: calling currval() before nextval() patch adding