populate primary keys
I am practising developing and application.
I am just confused about the autogenerated primary-key ID
in a certain table, and how to populated it to the corresponding
child table. It is like this:
A. Parent Table.
I got an employee table EMP (emp_id, name)
with primary key emp_id , auto generated by a trigger.
B. Child Table.
I got a 2nd table EMP_LOANS (loan_id,emp_id,amount)
With foriegn key emp_id renferences EMP.emp_id
with primary key loan_id , auto generated by a trigger.
My problem is, when i encode data to the 2 tables, i only
supply the EMP.name and EMP_LOANS.amount because the id's
are auto generated.
So what i see(enterable) in the screen form are just the fields
How do i pick up the EMP.emp_id and populate it to
Thanks a lot
hey davey,....do u understand my questions above?
That depends on your app. But you cannot expect Oracle to track that value. Assuming that the pkey of the parent table is set using a trigger then use the returning clause on the insert into EMP table in order to use it for the insert into the EMP_LOANS table.
Originally Posted by yxez
this space intentionally left blank
Thanks gandy....well, what i did was not to allow the trigger to populate the ID fields....i do select(nextval) it myself in the program
so i can get hold control of it
Last edited by yxez; 09-07-2006 at 12:15 AM.
Click Here to Expand Forum to Full Width