Temp Table In SQL Function - Mailing list pgsql-general

From
Subject Temp Table In SQL Function
Date
Msg-id 200109080348.31c5@lh00.opsion.fr
Whole thread Raw
List 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






pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: recursive text construction in plpgsql?
Next
From: caldodge@fpcc.net (Calvin Dodge)
Date:
Subject: Re: Problem w/ dumping huge table and no disk space