I think you can do what you want without the case statement:
create table t1 (c1 varchar2(10), c2 varchar2(10)); alter table t1 add constraint t1_chk1 check ( (c1 = '-' and c2 is null) or (c1 != '-' and c2 is not null) );
Now try pasting some values:
SQL> insert into t1 values ('-', 'reject'); insert into t1 values ('-', 'reject') * ERROR at line 1: ORA-02290: check constraint (SODONNEL.T1_CHK1) violated SQL> SQL> insert into t1 values ('-', null); 1 row created. SQL> SQL> insert into t1 values ('a', null); insert into t1 values ('a', null) * ERROR at line 1: ORA-02290: check constraint (SODONNEL.T1_CHK1) violated SQL> SQL> insert into t1 values ('a', 'accept'); 1 row created.
source share