Insert trigger problem


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Insert trigger problem

  1. #1
    Helmut Guest

    Insert trigger problem


    Hi!

    I am having an interesting problem here:

    A user is inserting a record into table A. This table has an after insert
    trigger associated with it that inserts three rows in table RESULT.
    Shortly after that, the user inserts a record into table B. This table has
    an after insert trigger associated with it that inserts 500 rows in table
    RESULT.

    Now the user goes back to table A and inserts another record into table A,
    which causes the trigger to insert another three recors in the table RESULTS.
    Then the user inserts into table B again... And so on and so forth.

    The question is: does the trigger on table A (when it is called the second
    time) wait for the 500 records from the table B trigger to be inserted or
    does it fire right away when the user inserts another record?

    The deal is that we need the records in the RESULT table to be in a specific
    order. In other words: the trigger on table A would have to 'wait' for the
    trigger on table B (that is inserting far more records) to finish before
    it is executing again.

    Is there any way to do that?

    Does anybody have an idea how SQL Server 7 handles that problem?

    Thanks,
    Helmut


  2. #2
    D. Patrick Hoerter Guest

    Re: Insert trigger problem

    Helmut,

    If all transactions for this user are executing on the same connection,
    they will be carried out in the order of execution, including their
    triggers. However, you have a more serious architectural issue here, and
    that is one of RDBMS usage. A database server has no concept of 'in the
    right order'. The data engine simply does not work that way. Perhaps you
    could clarify that part of it.

    Regards,
    D. Patrick Hoerter

    Helmut <hdaiminger@vivonet.com> wrote in message
    news:3a3a6618$1@news.devx.com...
    >
    > Hi!
    >
    > I am having an interesting problem here:
    >
    > A user is inserting a record into table A. This table has an after insert
    > trigger associated with it that inserts three rows in table RESULT.
    > Shortly after that, the user inserts a record into table B. This table has
    > an after insert trigger associated with it that inserts 500 rows in table
    > RESULT.
    >
    > Now the user goes back to table A and inserts another record into table A,
    > which causes the trigger to insert another three recors in the table

    RESULTS.
    > Then the user inserts into table B again... And so on and so forth.
    >
    > The question is: does the trigger on table A (when it is called the second
    > time) wait for the 500 records from the table B trigger to be inserted or
    > does it fire right away when the user inserts another record?
    >
    > The deal is that we need the records in the RESULT table to be in a

    specific
    > order. In other words: the trigger on table A would have to 'wait' for the
    > trigger on table B (that is inserting far more records) to finish before
    > it is executing again.
    >
    > Is there any way to do that?
    >
    > Does anybody have an idea how SQL Server 7 handles that problem?
    >
    > Thanks,
    > Helmut
    >




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center