Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

When Others Exception

Status
Not open for further replies.

Glowworm27

Programmer
May 30, 2003
587
US
I was hoping someone could clarify something for me.

I was reading the Online Documentation about dealing with exceptions and I was wondering about the When Others Exception.

If I do not list any other type of exception in my Exception block, will the When Others Exception catch ALL errors?

Code:
EXCEPTION
		When Others Then
		err_msg := SUBSTR(SQLERRM, 1, 200);
		Insert Into Payroll_Exceptions
		Values(Payroll_Exception_ID_Seq.Nextval, systimestamp, 'spInsertLabor_Dist', err_msg , oCreateDate, Null, Null, Null);

or do I need at least one other type of exception preceding the When Others Statement?

Thanks in advance

George Oakes
Check out this awsome .Net Resource!
 
One point to remember though:
When others traps all exceptions that are not yet handled so this should always be the last exception handler in the exception block.

Regards,
AA
 
Sem and Amrita are absolutely correct. I'll add just one clarification: "WHEN OTHERS..." must be the last exception handler in an exception section, otherwise, Oracle (PL/SQL) throws a interpret-time error.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[ Providing low-cost remote Database Admin services]
Click here to join Utah Oracle Users Group on Tek-Tips if you use Oracle in Utah USA.
 
OK I knew it had to be the last handler in the exception block. My question was if it is the only handler in the exception block would it catch All exceptions?

And I think Sem has answered that for me. Thanks everyone for your guidance.
[cannon]

George Oakes
Check out this awsome .Net Resource!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top