Constriant
610101Nov 9 2009 — edited Dec 1 2009I want to add a constriant to restrict the insert on a Table after checking the qty in a column of another Table.
For ex: I have
TABLE1
CR_ID
FINISH
QTY
TABLE2
CRI_ID
CRI_CR_ID
R_CODE
R_QTY
Suppose QTY is 100 (100 is the qty for FINISH product)
And R_CODE is raw material code, which in various combination makes one FINISH.
Inorder to produce FINISH of 100 qty, two or three R_CODE are entered.(For ex: for difference R_CODE'S different R_QTY ( 50, 10, 40 ))
At anytime the sum of R_QTY should not exceed QTY
i.e SUM(R_QTY) = QTY
where CR_ID = CRI_CR_ID
I don't know how to handle this. shall i write constraint ? But how can i write a constraint on one table based on value on another table?
Yogesh