ALTER PROCEDURE [dbo].[AdminSectionFactLinkSave]
@RegXML AS XML
AS
BEGIN
BEGIN TRY
BEGIN TRANSACTION
DECLARE @SectionFact AS INT
DELETE FROM SectionFactKnowFactLink WHERE SFKF_SFID IN (
SELECT SectionFactLink.ITEM.query('./SFKF_SFID').value('.','INT')
FROM @RegXML.nodes('/DocumentElement/SectionFactLink') AS SectionFactLink(ITEM))
INSERT INTO SectionFactKnowFactLink(SFKF_SFID,SFKF_KFMasterID)
SELECT SectionFactLink.ITEM.query('./SFKF_SFID').value('.','INT'),
SectionFactLink.ITEM.query('./SFKF_KFMasterID').value('.','INT')
FROM @RegXML.nodes('/DocumentElement/SectionFactLink') AS SectionFactLink(ITEM)
WHERE SectionFactLink.ITEM.query('./SFKF_KFMasterID').value('.','INT') > 0
COMMIT
RETURN 0
END TRY
BEGIN CATCH
EXEC CatchError
IF @@TRANCOUNT > 0 ROLLBACK
RETURN -1
END CATCH
END
****************************************************************************
Catch Error:
CREATE PROCEDURE [dbo].[CatchError]
AS
BEGIN
--To keep the error message
Declare @ErrMsg as varchar(1000)
BEGIN TRY
INSERT INTO dbo.Error_Log(Error_Date,Error_Msg,Error_Number,Error_Source )
SELECT DATEADD(HOUR, 20, GETDATE()), ERROR_MESSAGE() ,ERROR_NUMBER(), ERROR_PROCEDURE()
END TRY
BEGIN CATCH
END CATCH
set @ErrMsg = ERROR_MESSAGE()
Raiserror(@ErrMsg -- Error Message
, 16 --Severity Level
, 1 --State
)
END
@RegXML AS XML
AS
BEGIN
BEGIN TRY
BEGIN TRANSACTION
DECLARE @SectionFact AS INT
DELETE FROM SectionFactKnowFactLink WHERE SFKF_SFID IN (
SELECT SectionFactLink.ITEM.query('./SFKF_SFID').value('.','INT')
FROM @RegXML.nodes('/DocumentElement/SectionFactLink') AS SectionFactLink(ITEM))
INSERT INTO SectionFactKnowFactLink(SFKF_SFID,SFKF_KFMasterID)
SELECT SectionFactLink.ITEM.query('./SFKF_SFID').value('.','INT'),
SectionFactLink.ITEM.query('./SFKF_KFMasterID').value('.','INT')
FROM @RegXML.nodes('/DocumentElement/SectionFactLink') AS SectionFactLink(ITEM)
WHERE SectionFactLink.ITEM.query('./SFKF_KFMasterID').value('.','INT') > 0
COMMIT
RETURN 0
END TRY
BEGIN CATCH
EXEC CatchError
IF @@TRANCOUNT > 0 ROLLBACK
RETURN -1
END CATCH
END
****************************************************************************
Catch Error:
CREATE PROCEDURE [dbo].[CatchError]
AS
BEGIN
--To keep the error message
Declare @ErrMsg as varchar(1000)
BEGIN TRY
INSERT INTO dbo.Error_Log(Error_Date,Error_Msg,Error_Number,Error_Source )
SELECT DATEADD(HOUR, 20, GETDATE()), ERROR_MESSAGE() ,ERROR_NUMBER(), ERROR_PROCEDURE()
END TRY
BEGIN CATCH
END CATCH
set @ErrMsg = ERROR_MESSAGE()
Raiserror(@ErrMsg -- Error Message
, 16 --Severity Level
, 1 --State
)
END
3:52 AM |
Category: |
0
comments
Comments (0)