DBAsupport.com Forums - Powered by vBulletin
Results 1 to 6 of 6

Thread: Can a trigger be simultaneously fired by two sources?

  1. #1
    Join Date
    Nov 2005
    Posts
    4

    Exclamation 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

  2. #2
    Join Date
    Aug 2002
    Location
    Colorado Springs
    Posts
    5,253
    Can you demonstrate this behaviour with a script?
    David Aldridge,
    "The Oracle Sponge"

    Senior Manager, Business Intelligence Development
    XM Satellite Radio
    Washington, DC

    Oracle ACE

  3. #3
    Join Date
    Jan 2000
    Location
    Chester, England.
    Posts
    818
    Quote 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.

  4. #4
    Join Date
    Nov 2005
    Posts
    4
    Quote 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

  5. #5
    Join Date
    May 2000
    Location
    ATLANTA, GA, USA
    Posts
    3,135
    Can you post the fn and trigger here?

    Tamil

  6. #6
    Join Date
    Nov 2005
    Posts
    4
    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
  •  


Click Here to Expand Forum to Full Width