Subject | Optional FK constraint on 0 (not NULL) |
---|---|
Author | |
Post date | 2018-03-28T06:54:18Z |
Hi all
I have a transaction table that has an integer FK field. This FK field can be either a 0 (no master record selected) or an integer that is a FK value from the master PKs. If I put in a FK Constraint then it will not allow me a 0 in the transaction table's FK field. I know NULL is allowed but for the present I can't use NULL in the transaction table's FK field as it might impact other operations.
I have a transaction table that has an integer FK field. This FK field can be either a 0 (no master record selected) or an integer that is a FK value from the master PKs. If I put in a FK Constraint then it will not allow me a 0 in the transaction table's FK field. I know NULL is allowed but for the present I can't use NULL in the transaction table's FK field as it might impact other operations.
Is there an intermediate way to constraint only if a value > 0 is present in the transaction table's FK field. I need to stop a master record from deleting in case there is a reference.
Please advise
Kind regards
Bhavbhuti