Oracle: how to formulate a complex constraint with case when
check-constraints, oracle
Solution
Try the following:
ALTER TABLE eni_trasc_voci_pwr_fatt
ADD CONSTRAINT tvp_constraint_1 CHECK (
CASE WHEN TVP_CODICE_ASSOGGETAMEN = '-' THEN tvp_regione else null end IS NULL);
Problem
The following conditional constraint simply doesn't work. Is it possible to formulate in a working way? ``` ALTER TABLE eni_trasc_voci_pwr_fatt ADD CONSTRAINT tvp_constraint_1 CHECK ( CASE WHEN TVP_CODICE_ASSOGGETAMEN = '-' THEN tvp_regione IS NULL END); ```