X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 9399ED1B99E for ; Wed, 3 Sep 2003 20:43:17 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 44566-02 for ; Wed, 3 Sep 2003 17:43:09 -0300 (ADT) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id A66F1D1B98D for ; Wed, 3 Sep 2003 17:43:05 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id h83KgmJ24665; Wed, 3 Sep 2003 16:42:48 -0400 (EDT) From: Bruce Momjian Message-Id: <200309032042.h83KgmJ24665@candle.pha.pa.us> Subject: Re: [BUGS] session variable In-Reply-To: To: Peter Eisentraut Date: Wed, 3 Sep 2003 16:42:48 -0400 (EDT) Cc: sad , pgsql-sql@postgresql.org X-Mailer: ELM [version 2.4ME+ PL106 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200309/14 X-Sequence-Number: 14992 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 > > ------------- > > > > > > CREATE TEMP TABLE locals (name text, value text); > > INSERT INTO locals VALUES ('n1','xxx'); > > > > SELECT test_locals_access() ; > > > > column > > ------------- > > <=== 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, Pennsylvania 19073