Re: plpgsql: function throws error on second call! - Mailing list pgsql-general

From Stephan Szabo
Subject Re: plpgsql: function throws error on second call!
Date
Msg-id 20020726104029.G60864-100000@megazone23.bigpanda.com
Whole thread Raw
In response to plpgsql: function throws error on second call!  (Janning Vygen <vygen@gmx.de>)
Responses Re: plpgsql: function throws error on second call!  (Janning Vygen <vygen@gmx.de>)
List pgsql-general
On Fri, 26 Jul 2002, Janning Vygen wrote:

> i cant get it right on my own. i ve tried to find something in the
> bug reports and there was a bug with temp tables in functions years
> ago. but it was fixed..
>
> so here s my problem:
>
> CREATE FUNCTION testpunkte (int4) RETURNS int4 AS '
>   DECLARE
>     var_id ALIAS FOR $1;
>     var_count int4 := 0;
>   BEGIN
>
>     CREATE TEMP TABLE temp_punkte AS
>     SELECT * FROM tmp where id = var_id;
>
>    UPDATE real
>    SET    val1 = temp_punkte.val1
>    WHERE  id   = temp_punkte.id;
>    GET DIAGNOSTICS var_count = ROW_COUNT;
>    DROP TABLE temp_punkte;
>
>    RETURN var_count;
>    END;
> ' language 'plpgsql';

If you're going to create/drop a table in a function,
you'll want to use execute any time you're working with the
table, otherwise it'll cache the plan from the original table
that you've dropped.


pgsql-general by date:

Previous
From: "Marc G. Fournier"
Date:
Subject: Re: Bad HTML in Mail List Archives
Next
From: Patrick Nelson
Date:
Subject: Import csv