Re: Validation Trigger
DELIMITER $$
CREATE TRIGGER trigger1
BEFORE INSERT
ON invoice_details
FOR EACH ROW
BEGIN
IF NEW.due_date <= NOW() OR NEW.invoice_date <= NOW() OR NEW.shipping_total <=0 OR NEW.order_total <=0 OR NEW.total_cost <=0 THEN
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'Wrong values for invoice_details';
END IF;
END$$
DELIMITER ;
From the reference -
To signal a generic SQLSTATE value, use '45000', which means “unhandled user-defined exception.”
Devart Company,
MySQL management tools
http://www.devart.com/dbforge/mysql/
Subject
Views
Written By
Posted
5403
December 15, 2010 11:29AM
1742
December 15, 2010 12:06PM
1622
December 15, 2010 12:29PM
1525
December 15, 2010 01:04PM
1569
December 15, 2010 01:49PM
1347
December 15, 2010 02:43PM
1573
December 15, 2010 03:24PM
Re: Validation Trigger
1517
December 16, 2010 07:25AM
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.