Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 exception handling

Author  Topic 

TajKazi
Posting Yak Master

101 Posts

Posted - 2014-09-18 : 10:16:03
how to migrate exception handling script from oracle to sql server 2008

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2014-09-18 : 10:20:35
post some sample oracle exception handling code. let's see if we can translate it!
Go to Top of Page

TajKazi
Posting Yak Master

101 Posts

Posted - 2014-09-18 : 23:44:48
exception
when others then
rollback;
usp_iserror := 1;
pkg_exception_handler.usp_raise_error(-20001,pkg_atnot_configs.c_application_id,'pkg_atnot_main.usp_add_backdate_entry');
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2014-09-19 : 01:45:05
Use TRY...CATCH block:


BEGIN TRAN
BEGIN TRY
-- some code here
END TRY
BEGIN CATCH
IF @@TRANCOUNT > 0
ROLLBACK TRAN
SELECT ERROR_NUMBER() AS ErrorNumber, ERROR_LINE() AS ErrorLine, ERROR_MESSAGE() AS ErrorMessage
END CATCH

IF @@TRANCOUNT > 0
COMMIT TRAN


Harsh Athalye
http://www.letsgeek.net/
Go to Top of Page

Upendra Gupta
Starting Member

12 Posts

Posted - 2014-09-19 : 06:12:00
unspammed
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2014-09-19 : 06:16:32
Please don't spam here!

Harsh Athalye
http://www.letsgeek.net/
Go to Top of Page
   

- Advertisement -