Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

Implementing and Logging Error handling using PLSql in Sql Server 2005

Author: Zunnair

In This Article I will explains the way in which we can use try catch block like C#.net or VB.Net and also how we can Save Errors with properties to our log tables.

In This Article I will explains the way in which we can use try catch block like C#.net or VB.Net and also how we can Save Errors with properties to our log tables.

 

We must use try catch block in our Engine like procedures.

Engine like procedure are those procedures in which we basically call our all Procedures and Udfs(User defined Function Scalar or vector) in sequence to perform some sequential operations.

 

Just Follows the steps below to understand how we can use Error handling using Begin Try and End Try and Begin Catch and End Catch.

 

BEGIN TRY

EXECUTE [Procedure1]

EXECUTE [Procedure2]

EXECUTE [Procedure3]

END TRY

BEGIN CATCH

SET @Error_Message = (SELECT ERROR_MESSAGE() AS ErrorMessage)

SET @Error_Line = (SELECT ERROR_LINE() AS ErrorMessage)

SET @Error_Number = (SELECT ERROR_NUMBER() AS ErrorMessage)

SET @Error_Procedure = (SELECT ERROR_PROCEDURE() AS ErrorMessage)

INSERT INTO Error_Log

(

Error_Date,

Error_Procedure,

Error_Message,

Error_Line,

Error_Number

)

values

(

getdate(),

@Error_Procedure,

@Error_Message,

@Error_Line,

@Error_Number

)

END CATCH;

 

In this article I explain the way in which we can use error handling and also store in log tables I hope this article will helpful for you.

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< Using Truncate table in Procedure using Sql Server 2005.

Disclaimer - Privacy
© 2002-2017 DevASP.net