Skip site navigation (1) Skip section navigation (2)

TRigger catch delete on cascade from different table

From: Ludovico Bonifacio <ludoedgar(at)yahoo(dot)it>
To: pgsql-students(at)postgresql(dot)org
Subject: TRigger catch delete on cascade from different table
Date: 2011-02-09 01:30:35
Message-ID: 89587.12999.qm@web25603.mail.ukl.yahoo.com (view raw or flat)
Thread:
Lists: pgsql-students
hi everybody!
Could you help me please?
How do i do to  active a trigger (target is save the history from delete rows) 
without catch the event from the table where has created 
but catching the delete effect from a referenced value of other table? 

For example

CREATE TABLEDocument
(
id_document INTEGER PRIMARY KEY,
id_user INTEGER REFERENCES User(id_user) 
ON UPDATE CASCADE
ON DELETE CASCADE
);


CREATE TABLEUser
(
id_user INTEGER PRIMARY KEY,
username VARCHAR(20) NOT NULL,
pwd VARCHAR(30) NOT NULL,
email VARCHAR(30) NOT NULL
);


On Document table i defined a trigger 
AFTER DELETE ON Document

On User table i excute 
DELETE FROM User WHERE(condition); 
 
So, when i delete a user from User table, the trigger rightly doesn't recognise 
the DELETE because the recognise on Document.

Exists a way that let understand/catching at Trigger activing also in the case 
of deleting on cascade from other table?

Thanks in advanced
Greating



      

pgsql-students by date

Next:From: Cousin FlorenceDate: 2011-02-09 09:04:12
Subject: REĀ : [pgsql-fr-generale] create an extension of po?==?iso-8859-1?Q?stgresql 9 with Visual C++ 2008 express edition
Previous:From: Dimitri FontaineDate: 2011-02-08 21:37:38
Subject: Re: [pgsql-fr-generale] create an extension of postgresql 9 with Visual C++ 2008 express edition

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group