Question:
problem with foreign key in oracle 9i?
venkish m
17 years ago
i have two tables emp_master,emp_hw
emp_master.empno is primary key and emp_hw.empno is foreing key from emp_master

using jsp i inserted a value to emp_hw.empno ( insert into emp_hw values (' ');) a null value for which corresponding parent key in the table emp_master NOT THERE.
so i should get the error thet PARENT KEY NOT FOUND, but the non parent key value is inserted into emp_hw.empno
so this is violating the foreign key constraint.

if i am inserting same quary in sql this query is showing the error , only by using jsp is prob

what can i do
i should get that ereor and non-parent key should not be inserted

is this prob b coz of jsp ?
Three answers:
rk
17 years ago
Not entirely sure what your exact problem is but 1) a null value in a foreign key column doesn't cause a parent key not found. It will only validate that the parent is valid when you insert an actual value. 2) at a guess, the constraint is set to check at the end of the transaction, not the end of the statement and the jsp is issuing a commit between statements, that's why your statement works in SQL Plus but not jsp.
haroun
8 years ago
once you ran the installer, did you tell it to create your first database? in case you probably did no longer, there is not any database created; as a result, no username and password. in case you probably did create one, protection supervisor will up and asks you to specify device and inner account passwords at minimum.
Siva
17 years ago
make it as unique key in both table


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...