|
|
|
|
|
Re: need to find exception line no inside procedure of 1000 lines. [message #623020 is a reply to message #623006] |
Wed, 03 September 2014 06:46 |
Lalit Kumar B
Messages: 3174 Registered: May 2013 Location: World Wide on the Web
|
Senior Member |
|
|
hemant_khandare wrote on Wed, 03 September 2014 15:56 using exception handling.
If you have an exception handling, you can add dbms_utility.format_error_stack and dbms_utility.format_error_backtrace :
SQL> set serveroutput on;
SQL> CREATE OR replace PROCEDURE P_test
2 AS
3 l_deptno emp.deptno%TYPE;
4 BEGIN
5 SELECT deptno
6 INTO l_deptno
7 FROM emp;
8 EXCEPTION
9 WHEN OTHERS THEN
10 dbms_output.Put_line ('---------------------');
11
12 dbms_output.Put (dbms_utility.format_error_stack);
13
14 dbms_output.Put (dbms_utility.format_error_backtrace);
15
16 dbms_output.Put_line ('---------------------');
17
18 RAISE;
19 END;
20
21 /
Procedure created.
SQL> sho err;
No errors.
SQL> exec p_test;
---------------------
ORA-01422: exact fetch returns more than requested number of rows
ORA-06512: at
"SCOTT.P_TEST", line 5
---------------------
BEGIN p_test; END;
*
ERROR at line 1:
ORA-01422: exact fetch returns more than requested number of rows
ORA-06512: at "SCOTT.P_TEST", line 18
ORA-06512: at line 1
SQL>
But you shoould NOT have dbms_output in production code, so you need to log these errors in an error logging table.
Regards,
Lalit
|
|
|
|
|
Re: need to find exception line no inside procedure of 1000 lines. [message #623153 is a reply to message #623145] |
Fri, 05 September 2014 04:16 |
Lalit Kumar B
Messages: 3174 Registered: May 2013 Location: World Wide on the Web
|
Senior Member |
|
|
I deleted your duplicate message.
hemant_khandare wrote on Fri, 05 September 2014 14:27Thanks but why you used raise in others exception??
I have used RAISE to re-raise the error and that's what you need to do in order to propagate the error back to client. But, see how line number is changed and now it shows that of RAISE.
*
ERROR at line 1:
ORA-01422: exact fetch returns more than requested number of rows
ORA-06512: at "SCOTT.P_TEST", line 18 --> this is still wrong line number of error
ORA-06512: at line 1
Quote:Is there any other way to get error line no using exception handling mechanism??
Did you properly see what i explained above? There are two things in BOLD in my previous post. Read again.
|
|
|