Trigger Related Problem.....?

  • Dear All

    I have a table User_Master. I implemented a After trigger For Insert on this table. When i insert suppose 50 records then trigger fires 50 times but my requirement is that on inserting 50 reocords trigger should be fire once only.

     

  • If you insert the 50 records in a single insert statement using something like

    insert into User_Master(....)

    select blah1, blah2, blah3, etc

    from some_joined_tables

    then your trigger will fire once.

    If you issue 50 separate insert statements, your trigger will fire 50 times.  If this is not how you wish it to be, perhaps you should look at encapsulating the logic in one or more stored procedures?  Or, have a flag on the table (an extra bit column) called "processed".  Have this flag set as false by default for your new records.  Then have some timed event which gets the records with processed set false and does your processing in one go.  If a timed event is not suitable, a stored proc you run at the end of your 50 record insert could also do the trick?

  • This is the best of all 5 answers posted.  Does it answer your question or do you still need help?

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply