What is the output of the following pl/sql block ?declare v_empno emp.empno%type;begin select empno into v_empno from emp where empno = 10;exception when others then dbms_output.put_line ( 'no data found'); when no_data_found then dbms_output.put_line ( 'ther is no data found ');end;

when others then
*
ERROR at line 6:
ORA-06550: line 6, column 2:
PLS-00370: OTHERS handler must be last among the exception handlers of a block
ORA-06550: line 0, column 0:
PL/SQL: Compilation unit analysis terminated

Showing Answers 1 - 7 of 7 Answers

Suryam

  • Oct 18th, 2005
 

always when others exception should be the last exception handling in sequence.

  Was this answer useful?  Yes

Neerajms

  • Nov 21st, 2005
 

When Others is always handeled at the very end of all handeled exceptions. In this others should be in the last means after No_data_Found.

  Was this answer useful?  Yes

Lavanya Chowdary

  • May 6th, 2007
 

If you are using the exception part in the prg "others" exception should be the last exception that is the only mistake in the program.

  Was this answer useful?  Yes

The above PL/SQL code will throw an oracle exception ORA - 06550.

This is due the fact that the 'OTHERS'  exception block must be at the last of all the exception in a BEGIN END block.

In the above code if we put the no_data_found exception in the first place and the others exception after that  then the  code will work properly.

when others then
*
ERROR at line 6:
ORA-06550: line 6, column 2:
PLS-00370: OTHERS handler must be last among the exception handlers of a block
ORA-06550: line 0, column 0:
PL/SQL: Compilation unit analysis terminated

This is right answer

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.