0
这里是我的代码:Try-Catch:我如何捕获一个值来记录它?
BEGIN TRY
update [MicrosoftDynamicsAX].[dbo].[SALESLINE]
set recid = i.recid
FROM [Integration].[dbo].[CrmOrderDetails] c WITH(NOLOCK)
left outer join [MicrosoftDynamicsAX].[dbo].[SALESTABLE] s WITH(NOLOCK)
on cast(c.salesorderid as varchar(50)) = s.CRMGUID
left outer join [MicrosoftDynamicsAX].[dbo].[INVENTTABLE] it WITH(NOLOCK)
on it.NAMEALIAS = c.productidname
left outer join [MicrosoftDynamicsAX].[dbo].[INVENTTABLEMODULE] i WITH(NOLOCK)
on it.ITEMID = i.ITEMID
and i.MODULETYPE = 2 -- sales order
left outer join [MicrosoftDynamicsAX].[dbo].[SALESLINE] sl WITH(NOLOCK)
on sl.SALESID = s.SALESID
and sl.ITEMID = it.itemid
END TRY
BEGIN CATCH
INSERT INTO [Integration].[dbo].[PackageError]
([ID]
,[PackageName]
,[PackageStep]
,[ErrorDescription])
SELECT 'RECID VALUE HERE', 'CrmToAxOrders', 'UpdateSalesLineSP', ERROR_MESSAGE() ;
END CATCH
如何获得i.recid值错误,所以我可以登录到PackageError表?我没有看到确定哪个recid导致错误的方法。
谢谢