Re: [BUGS] session variable - Mailing list pgsql-sql

From Bruce Momjian
Subject Re: [BUGS] session variable
Date
Msg-id 200309032042.h83KgmJ24665@candle.pha.pa.us
Whole thread Raw
In response to Re: [BUGS] session variable  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-sql
Peter Eisentraut wrote:
> sad writes:
> 
> > The first problem using temp table is:
> >
> > CREATE TABLE locals (name text, value text);
> >
> > CREATE OR REPLACE FUNCTION test_locals_access() RETURNS text AS '
> > DECLARE i text;
> > BEGIN
> > SELECT value INTO i FROM locals WHERE name=''n1''
> > RETURN i;
> > END;
> > ' LANGUAGE 'plpgsql';
> >
> > SELECT test_locals_access() ;
> >
> > column
> > -------------
> > <null>
> >
> > CREATE TEMP TABLE locals (name text, value text);
> > INSERT INTO locals VALUES ('n1','xxx');
> >
> > SELECT test_locals_access() ;
> >
> > column
> > -------------
> > <null>                   <=== the Function seing global table
> 
> This is a problem in plpgsql, not in temporary tables.

Yes, see the FAQ.  You have to use EXECUTE for temp table access in
functions.

--  Bruce Momjian                        |  http://candle.pha.pa.us pgman@candle.pha.pa.us               |  (610)
359-1001+  If your life is a hard drive,     |  13 Roberts Road +  Christ can be your backup.        |  Newtown Square,
Pennsylvania19073
 


pgsql-sql by date:

Previous
From: "Antony Gubert"
Date:
Subject: unsubscribe
Next
From: sad
Date:
Subject: pg_type and type names