ALTER PROCEDURE [dbo].[Update_MCR]
@xmlString ntext
,@Message nvarchar(500) output
AS
BEGIN
SET NOCOUNT ON;
declare @SL int,@Basic float, @Grad_pay float, @DA float, @HRA float, @MA float, @Ptax float, @Itax float, @pf float, @LIC float, @Month_Of datetime
Declare @intDoc1 as int
BEGIN TRANSACTION
print @xmlString
exec sp_xml_preparedocument @intDoc1 OUTPUT, @xmlString
declare Generate_Rq CURSOR FOR
SELECT SL,Basic, Grad_pay, DA, HRA, MA, Ptax, Itax, pf, LIC, Month_Of
FROM OPENXML (@intDoc1,'/Salary/TransactionSalary',1)
WITH ( SL int,Basic float, Grad_pay float, DA float, HRA float, MA float, Ptax float, Itax float, pf float, LIC float, Month_Of datetime)
OPEN Generate_Rq
FETCH next FROM Generate_Rq
INTO @SL,@Basic, @Grad_pay, @DA, @HRA, @MA, @Ptax, @Itax, @pf, @LIC, @Month_Of
WHILE @@Fetch_Status<>-1
BEGIN
Print 'Line ' +@Basic+ ' '+ @Grad_pay+ ' '+ @DA+ ' '+ @HRA+ ' '+ @MA+ ' '+ @Ptax+ ' '+ @Itax+ ' '+ @pf+ ' '+ @Month_Of+ ' '+ @LIC+ ' '+ @SL
UPDATE [Monthly_Salary_Statement]
Set [Basic]=@Basic, [Grad_pay]=@Grad_pay, [DA]=@DA, [HRA]=@HRA, [MA]=@MA, [Ptax]=@Ptax, [Itax]=@Itax, [pf]=@pf, [LIC]=@LIC
Where [SL]=@SL and month([Month_Of])=month(@Month_Of) and year([Month_Of])=year(@Month_Of)
if(@@ERROR<>0)
BEGIN
rollback transaction
Set @Message='sp_Update_Montly_Salary: ' + @@Error
close Generate_Rq
deallocate Generate_Rq
Return
END
FETCH next FROM Generate_Rq
INTO @SL,@Basic, @Grad_pay, @DA, @HRA, @MA, @Ptax, @Itax, @pf, @LIC, @Month_Of
END
CLOSE Generate_Rq
DEALLOCATE Generate_Rq
COMMIT TRANSACTION
set @Message='True'
END
示例 XML:
<Salary>
<TransactionSalary SL="8" Basic="12560.00" Grad_pay="4800.00" DA="7812.00" HRA="2604.00" MA="300.00" Ptax="150.00" pf="2000.00" Itax="200.00" LIC="0.00" Month_Of="20-Dec-2012" />
<TransactionSalary SL="7" Basic="9860.00" Grad_pay="4100.00" DA="6282.00" HRA="2094.00" MA="300.00" Ptax="150.00" pf="2000.00" Itax="0.00" LIC="0.00" Month_Of="20-Dec-2012" />
<TransactionSalary SL="9" Basic="11850.00" Grad_pay="4800.00" DA="7493.00" HRA="2498.00" MA="300.00" Ptax="150.00" pf="2000.00" Itax="0.00" LIC="200.00" Month_Of="20-Dec-2012" />
</Salary>'
错误:
消息 8115,级别 16,状态 8,过程 Update_MCR,第 42 行
算术溢出错误将十进制转换为数据类型数字。
我无法找出为什么会发生此错误以及为哪个值。在插入的情况下,我采取另一种方式,如本网站所述。但又一次面临同样的问题。