6 Replies Latest reply on Jul 16, 2009 2:41 PM by 591186

    Conditional check inside CHECK Constraint

    707508
      All,


      is this possible to create a CHECK CONSTRAINT based on some condition?

      ALTER TABLE ACC ADD
      CONSTRAINT CK_01 CHECK
      (IS_RETURN
      (
      CASE WHEN ACC_NO IS NOT NULL THEN
      IS_RETURN IS NOT NULL
      END
      )
      )


      IF Account number is not null then IS_RETURN column should not allow null value.
      IF Account number is null then IS_RETURN column can accept null value.