plpgsql: function throws error on second call!

From: Janning Vygen <vygen(at)gmx(dot)de>
To: pgsql-general(at)postgresql(dot)org
Subject: plpgsql: function throws error on second call!
Date: 2002-07-26 17:27:01
Message-ID: 200207261727.g6QHR1M03244@janning.planwerk6.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

hi,

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';

it is just a dummy function on some testdata in my testdatabase
but if i call it two times:

testarea=# select testpunkte(1);
testpunkte
------------
1
(1 row)

fisrt time is fine and second time:

testarea=# select testpunkte(1);
NOTICE: Error occurred while executing PL/pgSQL function testpunkte
NOTICE: line 9 at SQL statement
ERROR: Relation 7842984 does not exist

it seems to me the temp table is not generated in the second call of
the function.

but i dont know anything about system tables and so on so i cant
check it.

any hints or am i just stupid and dont see a typo?? but if the
function makes it right on the first call it cant be a typo.

hmm. looks strange to me. can anybody give me small hint, please?

kind regards
janning

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Marc G. Fournier 2002-07-26 17:31:53 Re: Bad HTML in Mail List Archives
Previous Message Bruno Wolff III 2002-07-26 17:15:42 Re: Advice on geolocation