问题
Possible Duplicate:
raise error within MySql function
In MsSQL I can raise a custom error:
CREATE TRIGGER [dbo].[TR__TABLE__DisableRowOnDelete]
ON [dbo].[TABLE]
INSTEAD OF DELETE
AS
BEGIN
RAISERROR ('Data cannot be deleted.', 16, 1);
END
How might I do that in MySQL?
回答1:
In MySQL 5.5 you can use a SIGNAL statement, e.g. -
CREATE PROCEDURE TR__TABLE__DisableRowOnDelete()
BEGIN
SIGNAL SQLSTATE '02000' SET MESSAGE_TEXT = 'Data cannot be deleted.';
END
来源:https://stackoverflow.com/questions/8913999/custom-errors-in-mysql-trigger