Skip site navigation (1) Skip section navigation (2)

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 (view raw, whole thread or download thread mbox)
Lists: pgsql-general

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 '
    var_id ALIAS FOR $1;
    var_count int4 := 0;

    CREATE TEMP TABLE temp_punkte AS
    SELECT * FROM tmp where id = var_id;

   UPDATE real
   SET    val1 = temp_punkte.val1 
   WHERE  id   =;
   DROP TABLE temp_punkte;
   RETURN var_count;
' 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);
(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


pgsql-general by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group