使用mysql TRIGGER进行错误处理

时间:2016-09-23 03:46:38

标签: mysql error-handling

这是我显示错误处理的触发器:

DELIMITTER //

CREATE TRIGGER NOTA_PENJUALAN_INS BEFORE INSERT ON nota_penjualan FOR EACH ROW  
BEGIN
DECLARE VDATE DATETIME;

 If (NEW.INVENTORY_OUT_ID IS NOT  NULL) then

 CALL STATUS_INV_OUT(NEW.INVENTORY_OUT_ID);
 SELECT (a.DOCUMENT_DATE) INTO VDATE 
 FROM inventory_out a 
 INNER JOIN NOTA_PENJUALAN b ON a.INVENTORY_OUT_ID=b.INVENTORY_OUT_ID
 WHERE b.NOTA_PENJUALAN_ID=NEW.NOTA_PENJUALAN_ID;
 End IF;

IF(VDATE > NEW.DOCUMENT_DATE) THEN   
 SIGNAL SQLSTATE '45000'
 SET MESSAGE_TEXT = 'sorry can not exceed the date that has been specified';
END IF; 
END
//

显示:

enter image description here

并且不显示我的ShowMessage。

0 个答案:

没有答案