Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Help master detail trigger

Author  Topic 

mariechristine
Starting Member

27 Posts

Posted - 2004-10-12 : 09:50:47
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????

X002548
Not Just a Number

15586 Posts

Posted - 2004-10-12 : 10:18:38
Join on OrderId?



Brett

8-)
Go to Top of Page

mariechristine
Starting Member

27 Posts

Posted - 2004-10-13 : 02:57:14
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

Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2004-10-13 : 03:46:12
quote:
Originally posted by mariechristine

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





but isn't that what you want? using a join i mean...

to know which order id in torderdetail was updated and corresponding to the order id in torder, we're assuming here that TOrder is somewhat your header table and TOrderDetail is your details table.

--------------------
keeping it simple...
Go to Top of Page
   

- Advertisement -