I have a table called TEST:
PAR CHLD
---------------------- ----------------------
1 2
1 3
1 4
2 5
3 6
The PAR and CHLD column form a composite primary key.
My requirement is that if I'm updating a value in the CHLD column it should only accept any of the existing values in the column.
This should fail because value 7 is not in column CHLD:
UPDATE TEST SET CHLD = 7 WHERE PAR = 3;
This should succeed because value 4 is in column CHLD
UPDATE TEST SET CHLD = 4 WHERE PAR = 3;
Please note I cannot have check constraint for fixed values as I dont know the list of values during table design.