I have a table T with two fields A and B of type integer.
Now I want to enforce that A is smaller or equal to B.
Do I have to create a “before insert/update”-trigger?
And if yes then how do I make the trigger fail?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You could do it in your application code, but it’s safest to do it in the database via a trigger.
To prevent the insert from succeeding, generate an error in your trigger. We do something like this: