Programming :  Student Freelance Forum For Work Experience Builders' (CertificationPoint) The fastest message board... ever.
 
When I try to Insert data I got this error : Arithmetic overflow error converting expression to data type int
Posted by: adcertpoint (Moderator)
Date: July 22, 2021 07:15PM

When I try to Insert data to my table I got following error.

Msg 8115, Level 16, State 2, Procedure trig_stockUpdate, Line 6 [Batch Start Line 3]
Arithmetic overflow error converting expression to data type int.

When I insert data to my table stock will be automatically updated. as you can see here my trigger for updating stock.

USE [wccdb]
GO

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER TRIGGER [dbo].[trig_stockUpdate]
ON [dbo].[tblPermanentInvoice]
AFTER INSERT
AS
BEGIN
UPDATE p
SET quantity = COALESCE(d.quantity, 0) - COALESCE(i.quantity, 0)
FROM tblCurrentPurchased p
LEFT JOIN
(SELECT ItemCode, quantity
FROM inserted i) i ON p.ItemCode = i.ItemCode
LEFT JOIN
(SELECT d.ItemCode, SUM(d.quantity) AS quantity
FROM tblCurrentPurchased d
GROUP BY d.ItemCode) d ON p.ItemCode = d.ItemCode
WHERE
d.quantity > 0
OR i.quantity > 0;
END

Can you please tell me how can I solve this problem.

Options: ReplyQuote


Sorry, only registered users may post in this forum.
This forum powered by Phorum.