Help master detail trigger

  • I have table order(orderid (identity), orderdate)

       and table orderDetail (orderDetailID(identity),orderid,           productID, qty)

    and trace tables:

    Table TOrder(orderid, orderdate, actionid, actionDate, actionUser)

    Table TOrderDetail(orderdetailID, orderID, productID, qty, actionid, actionDate, actionUser)

    --actionid=1:means: insert, actionid=2:means: update, actionid=3:means: delete

    There can be many updates on table order and many updates on OrderDetail.

    What can i do to know which rows of TOrderDetail is for TOrder????

  • I would assume you'd join the TOrderDetail to the TOrder based on the OrderID column.

  • NO join is not a solution. join might give wrong records. The same order id 10 might be updated several times with order detail 1,2,3.

    I have triggers on order and orderDetail to insert in Torder and TorderDetail tables.

    So how am going to know wich update of TorderDetail with order id 10 corresponds to which update of Torder order id 10

     

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

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