Skip to Main Content
  • Questions
  • How to detect where error occurred in PL/SQL

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question.

Asked: January 31, 2018 - 6:05 pm UTC

Last updated: February 01, 2018 - 2:05 am UTC

Version: 11.0

Viewed 1000+ times

You Asked

If i'm having a procedure with three select statements while debugging how will u find exactly in which statement u r getting error?

and Connor said...

Easy...the error will tell you exactly where it went wrong

SQL> create or replace procedure p is
  2    x int;
  3  begin
  4    -- this one will work
  5    select 1 into x from dual;
  6
  7    -- this one will work
  8    select 1 into x from dual;
  9
 10    -- this one will FAIL
 11    select 1 into x from dual where 1=0;     <======LINE 11
 12
 13    -- this one will work
 14    select 1 into x from dual;
 15
 16    -- this one will work
 17    select 1 into x from dual;
 18
 19  end;
 20  /

Procedure created.

SQL>
SQL>
SQL> exec p
BEGIN p; END;

*
ERROR at line 1:
ORA-01403: no data found
ORA-06512: at "MCDONAC.P", line 11       <======LINE 11
ORA-06512: at line 1



Is this answer out of date? If it is, please let us know via a Comment

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library