#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2004
    Posts
    2
    Rep Power
    0

    exception after check constraint


    Hi
    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?
  2. #2
  3. Big Endian
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    May 2001
    Location
    Fly-over country
    Posts
    1,172
    Rep Power
    30
    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.

IMN logo majestic logo threadwatch logo seochat tools logo