April 2, 2015 at 6:39 am
my client has a stored procedure triggered by shipping action - basically adding an indicator to a shipping file depending on quantities in a shipping table
if the shipping record quantity is greater than the driver table amount then the indicator gets updated with the driver record quantity and the record is cloned with the remaining quantity minus the indicator
later records in the driver table don't "see" the records just added
if I wrap the INSERT statement in a TRANsaction and COMMIT it will it then add the record? and will it update everything processed to this point?
this is a critical action and I don't want to kill it
April 2, 2015 at 6:53 am
Probably not, but without seeing the proc and having more details on the process, hard to say.
Just wrapping something in a transaction is seldom the answer.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
April 3, 2015 at 6:24 am
You're doing an INSERT and then want to use the values inserted later within the same query? How about using the OUTPUT clause to capture the values into either variables or a temporary table?
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
April 4, 2015 at 7:44 am
Grant - that's an interesting solution, which I might just pursue - thanks
Gail - I am under contract at a client hyper sensitive to intellectual material being stolen - when I posted SQL code that was rewritten (from a suggestion by Mr. Moden) the lawyers made me erase it, even though I renamed anything that could have pointed to the identity of the client - so I am being vague out of necessity
April 4, 2015 at 8:13 am
Seggerman-675349 (4/2/2015)
my client has a stored procedure triggered by shipping action - basically adding an indicator to a shipping file depending on quantities in a shipping tableif the shipping record quantity is greater than the driver table amount then the indicator gets updated with the driver record quantity and the record is cloned with the remaining quantity minus the indicator
later records in the driver table don't "see" the records just added
if I wrap the INSERT statement in a TRANsaction and COMMIT it will it then add the record? and will it update everything processed to this point?
this is a critical action and I don't want to kill it
Is it absolutely necessary to generate all such intermediate rows for each and every action or can you just generate 1 per batch no matter how many such actions there are?
--Jeff Moden
Change is inevitable... Change for the better is not.
April 4, 2015 at 10:42 am
the records INSERTed then need to be available to be updated by subsequent records in the driver table - I guess I can say that they are receipt records which need to be applied to order allocation records (except that they aren't) - the receipt records need to be processed in a certain order and the allocation records need to be fulfilled in a certain order as well
what is happening is that the fulfillment order is not happening in the correct order due to these intermediate records and the web pages the user sees shows odd gaps
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply