I have an SP that, among other things, needs to sum some values and play with it. It seems to be dying, because all I get is the two selected values at the top:
When I run this in QA, I see the CurrentSum and Quantity values, but nothing else. I can't get QA to print anything at all, so I can't find out what the combined value of the two is or if it's even entering the if/else clause.
What am I doing wrong?
thanks!
tigerjade
"Always code as if the person who ends up maintaining your code will be a violent psychopath who knows where you live." -- Martin Golding
Code:
ALTER PROCEDURE sp_addItemsAccounting
@ItemID int
,@Received int
,@UserID int
,@InvoiceID int
,@Success int Output
AS
DECLARE @Quantity int, @CurrentSum int
SELECT CONVERT(int, Quantity) AS Quantity FROM Item WHERE ID = @ItemID
SELECT SUM(Received) AS CurrentSum FROM OutstandingItemsAccounting WHERE ItemID = @ItemID
IF (@Quantity >= (@CurrentSum + @Received))
BEGIN
IF NOT EXISTS (SELECT ID FROM OutstandingItemsAccounting WHERE ItemID = @ItemID AND DATEDIFF(ss, DateVerified, GetDate()) < '10')
BEGIN
INSERT INTO OutstandingItemsAccounting (ItemID, Received, DateVerified, UserID, InvoiceID)
VALUES (@ItemID, @Received, GetDate(), @UserID, @InvoiceID)
SET @Success = 1
END
ELSE
BEGIN
SET @Success = 0
END
END
ELSE
BEGIN
SET @Success = 0
END
GO
When I run this in QA, I see the CurrentSum and Quantity values, but nothing else. I can't get QA to print anything at all, so I can't find out what the combined value of the two is or if it's even entering the if/else clause.
What am I doing wrong?
thanks!
tigerjade
"Always code as if the person who ends up maintaining your code will be a violent psychopath who knows where you live." -- Martin Golding