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 5B7D7D1B8B0 for ; Tue, 2 Sep 2003 13:10:50 +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 56342-10 for ; Tue, 2 Sep 2003 10:10:43 -0300 (ADT) Received: from rock.spider.ru (rock.spider.ru [62.183.34.226]) by svr1.postgresql.org (Postfix) with ESMTP id 4A3D4D1B8A4 for ; Tue, 2 Sep 2003 10:10:39 -0300 (ADT) Received: from rock (localhost [127.0.0.1]) by rock (Postfix) with SMTP id 06A1591305 for ; Tue, 2 Sep 2003 17:10:42 +0400 (MSD) Received: from sad.localnet.ru (sad.localnet.ru [10.0.0.33]) by rock.spider.ru (Postfix) with ESMTP id 9A505912C9 for ; Tue, 2 Sep 2003 17:10:41 +0400 (MSD) Content-Type: text/plain; charset="iso-8859-1" From: sad Organization: IT To: pgsql-sql@postgresql.org Subject: Re: [BUGS] session variable Date: Tue, 2 Sep 2003 17:13:24 +0400 User-Agent: KMail/1.4.3 References: <200309011657.h81Gva817128@candle.pha.pa.us> <200309021629.26156.sad@bankir.ru> <3F548FD0.5070600@pse-consulting.de> In-Reply-To: <3F548FD0.5070600@pse-consulting.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200309021713.24846.sad@bankir.ru> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200309/8 X-Sequence-Number: 14986 On Tuesday 02 September 2003 16:40, you wrote: > No problem to use a temp table in a trigger (which is local to the > session), I do so myself. Still, session variables would be nice, making > coding a little bit more comfortable. (it would be very good if you implement session variables in PostgreSQL.) 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=3D''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 ------------- <=3D=3D=3D the Function seing global table SELECT value FROM locals WHERE name=3D'n1'; value --------- xxx the second problem may be resolved with your advise. look: i want to log operations on the data in some tables. so i declared sufficient triggers which write to the log-table. and now i want to mark each log-record with the "operator_id" (e.g. to log who made an update) what possible ways are there ? if i use temp table to inform the triggers about "operator_id" then i have problems in manual updates of these tables (temp table in my session needed too)