Get Value from Trigger
Hi,
I have two tables table A and table B, Table A has a trigger which inserts ID from trigger, The ID which got inserted from table A has to get also inserted into Table B as a foreign key,
Please find the below script am doing in this method, But I think this may affect some where need some alternative suggestion.
Begin
INSERT INTO A
( NAME, AGE) VALUES ( P_NAME, P_AGE) ;
End;
Note: In the above script ID is automatically inserted through trigger.
Declare
l_a_id number;
Begin
select max(id) into l_a_id from a;
INSERT INTO
( DEPT_NO, DEPT_NAME, A_ID) VALUES ( P_DEPT_NO, l_a_id, P_DEPT_NAME) ;
End;
Please check the above method which am doing is correct or not. If there is any alternative way please suggest me.
Thanks
Sudhir