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
  [EMAIL PROTECTED]               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Reply via email to