标签云

微信群

扫码加入我们

WeChat QR Code

If I have a trigger before the update on a table, how can I throw an error that prevents the update on that table?


Hi can you make a practical example on how to write the trigger in the link?I have two columns (idUser and idGuest) that must be mutually exclusive in the table orders, but i'm fairly new to triggers and i'm finding difficulties in writing it!Thx.

2018年07月18日35分56秒

In procedure insert_test if new.id < 0 isn't valid syntax if should if P_id < 0

2018年07月19日35分56秒

First hack is not working #1103 - Incorrect table name 'Error: invalid_id_test'.

2018年07月19日35分56秒

happy_marmoset, isn't the whole point to raise an error? By using The error text as a table name, the error is triggered and the insert is prevented. As I understand this is a way to do it, if your mysql < 5.5

2018年07月19日35分56秒

While this code snippet may solve the question, including an explanation really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion. Please also try not to crowd your code with explanatory comments, as this reduces the readability of both the code and the explanations!

2018年07月18日35分56秒