INSTEAD OF trigger on VIEWs - Mailing list pgsql-hackers

From --= Tono =--
Subject INSTEAD OF trigger on VIEWs
Date
Msg-id 20050523131519.74986.qmail@web53501.mail.yahoo.com
Whole thread Raw
Responses Re: INSTEAD OF trigger on VIEWs  (Christopher Kings-Lynne <chriskl@familyhealth.com.au>)
List pgsql-hackers
Is there any plans to create an INSTEAD OF trigger on
VIEWS?   I have view which consists of a master and
detail table.  When a row is inserted into the view,
the view needs to figure out if the master record
already exsists. If the record does not exists in the
master table, then insert into the master and the
detail table.  If the record already exists in the
master, just insert into detail table.  Conversely, if
a delete record is performed on the view, the view
needs to figure out if it only needs to delete from
the detail table, or should it also delete from the
master table when all the detail records are already
deleted.  In Oracle this is easily done using INSTEAD
OF triggers.  INSTEAD OF triggers can only be created
for VIEWs. The purpose of it is to "short-circuit" the
event (INSERT, UPDATE or DELETE) and perform whatever
is specified in the trigger.

CREATE OR REPLACE TRIGGER schema.trigger_name INSTEAD
OF INSERT ON object_name 
BEGIN
-- Perform the following instead --
END;



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


pgsql-hackers by date:

Previous
From: Richard Huxton
Date:
Subject: Re: subquery returning array
Next
From: Christopher Kings-Lynne
Date:
Subject: Re: INSTEAD OF trigger on VIEWs