Posted by: arnzombie June 12, 2008
ORACLE Constraints help
Login in to Rate this Post:     0       ?        

ORACLE CONSTRAINT HELP

I have two tables table A AND Table B.
Table is a fact table and can be modified by business only.
Nothing can be done to table A.

I need to insert data in table B but have to check with data in Table A.
I have to make sure that data being inserted to table B must exist in table A.OR else it should throw error.

table A

id name loc
1  DELL  Austin
2  HP    houston
3  Sony  Japan
 
Table B
id name  ship
1  dell  comp
1  dell  server
2  XXX   XXX
3  YYY   YYY

So if i try to insert in id column of table B which is not in id column of table A,then  it should throw error.
like if i try
insert into B values (5,ZZZ,ZZZ);
then i should get error saying cannot insert 5 in TABLE B column ID.

PS: I cannot use foreign key relation. The constraint is pretty much foreign key ..But cannot use forgeing key as we dont want hassle while deleting from TABLE A. or B.

Read Full Discussion Thread for this article