Re: How i can reject a row in a trigger?
Posted by:
Bob Field
Date: January 11, 2007 04:44PM
The solution I have worked out to abort a deletion via a before delete trigger is this:
DELIMITER $$
CREATE TRIGGER triggername BEFORE DELETE ON yourtable
FOR EACH ROW
BEGIN
DECLARE temp int;
SELECT `DELETE aborted` INTO temp FROM yourtable;
END$$
DELIMITER ;
This should abort the delete and leave the row(s) intact. Selecting a non-existent column name works to raise an error in triggers and stored routines. The bad column name can double as your error message. You can wrap whatever conditional you want around the SELECT statement.
Subject
Views
Written By
Posted
5625
January 11, 2007 09:51AM
2245
January 11, 2007 09:57AM
2919
January 11, 2007 10:30AM
2151
January 11, 2007 12:06PM
2219
January 11, 2007 04:19PM
Re: How i can reject a row in a trigger?
2276
January 11, 2007 04:44PM
2114
January 12, 2007 10:00AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.