March 24th, 2004, 10:08 AM
exception after check constraint
i wrote a check contraint in a table similar like this
ALTER TABLE TEST ADD CONSTRAINT CHK_TEST_DATE check (DATE1 <= DATE2);
is it possible do write my own exception when the constraint
definition is false?
March 29th, 2004, 07:15 PM
Instead of using a Check Constraint, you could check the condition using a trigger and raise an exception there. Take a look at the Data Definition .pdf documentation. Under the Stored Procedure section (page 165), they explain how to create a custom exception. In the next chapter under Triggers (page 192), they explain how to check the data for a condition whenever a change occurs and raise an exception if necessary.