Friday, 15 August 2014

sql - Constraint check with variable values -



sql - Constraint check with variable values -

i have table called test:

par chld ---------------------- ---------------------- 1 2 1 3 1 4 2 5 3 6

the par , chld column form composite primary key.

my requirement if i'm updating value in chld column should take of existing values in column.

this should fail because value 7 not in column chld:

update test set chld = 7 par = 3;

this should succeed because value 4 in column chld

update test set chld = 4 par = 3;

please note cannot have check constraint fixed values dont know list of values during table design.

create table, e.g. children, contains valid values (2,3,4,5,6). add together referential constraint test table children.

sql oracle

No comments:

Post a Comment