I have a trigger that is behaving strangely. The trigger is actioned when an order record is inserted and updates a customer record with the date and amount of the most recent order.
I am loading some test orders to the database via an INSERT:
Although I have verified that @OrdTxt contains valid numeric non-zero data and that both @OrdAmt and @RetAmt contain the correct values, the trigger only updates the date of the last order but puts zero in the amount of the last order. If I reinstate the line commented out, it does exactly what I believe it should do and updates the last order amount to 1957.00.
The FnuExtract function extracts a word from a string based on a supplied delimiter and returns varchar. There is an implication that it may be the culprit. I can supply
I can supply the code of the trigger itself but I cannot see how it could be at fault. I am utterly stumped!
I am loading some test orders to the database via an INSERT:
Code:
SET @OrdTxt = LTRIM(dbo.FnuExtract(@OrdLst,',',1))
SET @OrdAmt = CAST(@OrdTxt as smallmoney)
--SET @OrdAmt = CAST(LTRIM(' 1957.00') as smallmoney)
SET @RetAmt = ROUND(@OrdAmt*1.175,2)
INSERT Orders(CustId, OrdDate, NetAmt, RetailAmt)
VALUES (23,'01-May-2008',@OrdAmt, @RetAmt)
Although I have verified that @OrdTxt contains valid numeric non-zero data and that both @OrdAmt and @RetAmt contain the correct values, the trigger only updates the date of the last order but puts zero in the amount of the last order. If I reinstate the line commented out, it does exactly what I believe it should do and updates the last order amount to 1957.00.
The FnuExtract function extracts a word from a string based on a supplied delimiter and returns varchar. There is an implication that it may be the culprit. I can supply
I can supply the code of the trigger itself but I cannot see how it could be at fault. I am utterly stumped!