From: | Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> |
---|---|
To: | Janning Vygen <vygen(at)gmx(dot)de> |
Cc: | <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: plpgsql: function throws error on second call! |
Date: | 2002-07-26 17:42:43 |
Message-ID: | 20020726104029.G60864-100000@megazone23.bigpanda.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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.
From | Date | Subject | |
---|---|---|---|
Next Message | Patrick Nelson | 2002-07-26 17:45:24 | Import csv |
Previous Message | Marc G. Fournier | 2002-07-26 17:31:53 | Re: Bad HTML in Mail List Archives |