Curious how you handle copying to create a child list and then update with Parent ID?

in my use case I have an Order table with an Order ID. A child table is Order Details that lists the products include in the order. I then have a Saved Orders table used to pre-populate the Order Details with recurring/frequent orders.

When a Saved Order is selected, I copy the product details to the Order Details table and then need to update those Order Detail rows with the parent Order ID of the current order being constructed.

Since we do not have an โ€œUPDATE rows in another table with values from this rowโ€ type of action, I am wondering how any of you might handle the updating of the parent Order ID value into the newly created child rows?

So far, the most efficient, least intrusive way I can think of is to use a simple small table to capture the Order ID value just before the copy function and then retrieve that value from the table during the copy to be added to each new row.

Any better way?

0 8 490
8 REPLIES 8
Top Labels in this Space