Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id EAFAD47626C for ; Thu, 17 Oct 2002 10:44:53 -0400 (EDT) Received: from ien.ru (unknown [212.176.46.57]) by postgresql.org (Postfix) with ESMTP id D347E475F1B for ; Thu, 17 Oct 2002 10:44:51 -0400 (EDT) Received: from akulov ([192.168.2.7]) by ien.ru (8.11.4/8.11.4) with ESMTP id g9HIiCU19395 for ; Thu, 17 Oct 2002 22:44:12 +0400 Date: Thu, 17 Oct 2002 18:40:30 +0400 From: =?koi8-r?B?4cvVzM/XIOHMxcvTwc7E0g==?= X-Mailer: The Bat! (v1.60q) Personal Reply-To: =?koi8-r?B?4cvVzM/XIOEu9y4=?= X-Priority: 3 (Normal) Message-ID: <9736000265.20021017184030@ien.ru> To: pgsql-sql@postgresql.org Subject: Can I create working trigger on view MIME-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Transfer-Encoding: 8bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200210/228 X-Sequence-Number: 9945 Hello! Please, help me! Can I create working trigger on view? The problem is: I need a plpgsql function that execute on insert (or update, or delete) into view and knows the *OLD* and *NEW*. (Number of fields can be more than 16) Something like this: Create Sequence id; Create Table t1(id1 int4, last_name varchar(32), time_create_t1); Create Table t2(id2 int4, first_name varchar(32), time_create_t2); Create View name as Select * from t1 a, t2 b where a.id1=b.id2; Create Rule rl_ins_nameas on INSERT to name do instead nothing; -- without it trigger is not allowed Create Function fn_ins_name() returns opaque as ' Declare v_time_create timestamp; Begin v_tm_create:=current_timestamp; Insert into t1(id1, last_name, time_create_t1) values(nextval(''id''), new.last_name, v_time_create); Insert into t2(id2, first_name, time_create_t2) values(currval(''id''), new.first_name, v_time_create); return null; End; ' Language 'plpgsql'; Create Trigger tr_ins_name before INSERT on now_cis_user for each row execute procedure fn_ins_name; This example is very simple. The trigger is not fired. Sorry for my English. -- Thanks for everybody. Akulov Alexander. e-mail:akulov@ien.ru