Temp Table In SQL Function

From: <cnliou(at)eurosport(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Temp Table In SQL Function
Date: 2001-09-08 03:48:49
Message-ID: 200109080348.31c5@lh00.opsion.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello!

I am trying to create a sql function that returns 2
values using temporary table as the "media":

database1=# CREATE FUNCTION SaveNumeric(int2,int2)
RETURNS INTEGER AS '
database1'# CREATE TEMP TABLE mytemp(a int2,b int2);
database1'# INSERT INTO mytemp VALUES ($1+1,$2+100);
database1'# SELECT 1;
database1'# ' LANGUAGE 'sql';
ERROR: Relation 'mytemp' does not exist

But below seems to work:

database1=# CREATE FUNCTION Drop2Numeric() RETURNS
INTEGER AS '
database1'# DROP TABLE mytemp;
database1'# SELECT 1;
database1'# ' LANGUAGE 'sql';
CREATE

Why the creation of SaveNumeric(int2,int2) fails
while the creation of Drop2Numeric() succeeds?

Regards,

CN

--------------------------------------------------------
You too can have your own email address from Eurosport.
http://www.eurosport.com

Browse pgsql-general by date

  From Date Subject
Next Message Calvin Dodge 2001-09-08 05:05:49 Re: Problem w/ dumping huge table and no disk space
Previous Message Tom Lane 2001-09-08 02:46:33 Re: recursive text construction in plpgsql?