insert into master detail table
493871Feb 27 2006 — edited Feb 27 2006Hello experts,
I am not an expert in SQL but I have to use it to access the DB from within my application. I hav the following issue:
I would like to insert a record in a master table and at the same time a record in the detail table. If I use a seqeunce I can use the nextval and currval, but this method is not multiuser and thread safe. There is still a danger that before the insert of the detail record, the nextval is altered by an other process. How should it be done?
I now have to following queries which are not threadsafe:
INSERT INTO U_FINALRESULT(U_FINALRESULT_ID,NAME, VERSION,VERSION_STATUS)
VALUES (sq_U_FINALRESULT.NEXTVAL,'A NAME01','1','A');
INSERT INTO U_FINALRESULT_USER(U_FINALRESULT_ID,U_SAMPLE_ID,U_OPERATOR_ID)
VALUES (sq_U_FINALRESULT.CURRVAL,999,1);
Thank you very much, for taking the effort of thinking about my problem!!!