From: Акулов Александр <akulov@ien.ru>
To: pgsql-sql@postgresql.org
Subject: Can I create working trigger on view
Date: Fri, 18 Oct 2002 09:06:03 +0400
Message-ID: <1702162421.20021018090603@ien.ru> (raw)
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.
Acue.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: akulov@ien.ru
Subject: Re: Can I create working trigger on view
In-Reply-To: <1702162421.20021018090603@ien.ru>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox