-
Can a trigger be simultaneously fired by two sources?
I have a trigger before insert on a table. Now, I call a function which inserts a row into the table. Everything works fine and the trigger is fired.
But now, if I call the function many times simultaneously one after another, all the rows are inserted but trigger is fired only for the first row.
Why is this happening?
I have used dbms_lock.sleep call between two functions call and everything works fine. Is there any other way out? Otherwise, is using sleep fine.
PB
-
Can you demonstrate this behaviour with a script?
-
Originally Posted by pb23
I have a trigger before insert on a table. Now, I call a function which inserts a row into the table. Everything works fine and the trigger is fired.
But now, if I call the function many times simultaneously one after another, all the rows are inserted but trigger is fired only for the first row.
Well for a start you can't have a situation where the function executes "many times simultaneously one after another" It's either "simulateously" or "one after another" ... Pedantic? moi?
Do you mean that you insert many rows but the triggers only fires once? I suspsect you require "FOR EACH ROW" adding to your trigger definition. Otherwise the trigger fires just once per transaction.
-
Originally Posted by slimdave
Can you demonstrate this behaviour with a script?
I am calling the function in a script in this way:
...
num:=func_name(...);
num:=func_name(...);
num:=func_name(...);
.....
within this function a single row is inserted into the table, then function returns.
It is inserting well for all the calls, but the subsequent action based on trigger occurs only for the first call.
now inserting dbms_lock.sleep(1); between each func. call solves the problem, but causes an unwanted delay.
PB
-
Can you post the fn and trigger here?
Tamil
-
Thanks all, I have solved the problem, It was with a constraint on the table related with the timestamp being saved.
PB
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|