Subject Re: Check Constraint - Custom Exception
Author Adam
> I have a check constraint:
>
> ALTER TABLE EMPLOYEE ADD CONSTRAINT C_EMPLOYEE
> CHECK (
> new.GENDER <>'M'
> );
>
> and an Exception as:
>
> CREATE EXCEPTION EXC_BAD_GENDER 'Wrong sex!!';
>
> How do I raise the Exception EXC_BAD_GENDER when the check constraint
> fails? TIA
>

You will need to create a trigger to do the test.

CREATE OR ALTER TRIGGER EMPLOYEE_BI FOR EMPLOYEE
ACTIVE BEFORE INSERT OR UPDATE POSITION 0
AS
BEGIN
IF NEW.GENDER<> 'M' THEN
BEGIN
EXCEPTION EXC_BAD_GENDER;
END
END
^

What is wrong with female employees??

Adam