Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: How to get current program line number in exception?

Re: How to get current program line number in exception?

From: Jaap W. van Dijk <j.w.vandijk.removethis_at_hetnet.nl>
Date: Thu, 25 Apr 2002 20:20:52 GMT
Message-ID: <3cc864d5.1181063@news.jaapwvandijk.myweb.nl>


Richard,

Understood, finally and completely. Thanks for clearing that up.

Jaap.

On Thu, 25 Apr 2002 17:46:03 GMT, Richard Kuhler <noone_at_nowhere.com> wrote:

>You've read that wrong. The format_call_stack output has line 13 (the
>call to format_call_stack itself). The line 29 reference is the call
>stack after the error was raised and reported by sql*plus.
>
>Richard
>
>"Jaap W. van Dijk" wrote:
>>
>> Richard,
>>
>> You're right, I didn't look hard enough to what was actually output.
>>
>> About this line 29: the format_call_stack was executed and the output
>> put in variable vz BEFORE the raise on this line was executed: how
>> could this line reference appear in the output of format_call_stack?
>>
>> Jaap.
>>
>> On Wed, 24 Apr 2002 21:10:08 GMT, Richard Kuhler <noone_at_nowhere.com>
>> wrote:
>>
>> >Because these refer to lines 13 and 29, when the error itself occurred
>> >at line 10. Note: 13 is the "format_call_stack" line and 29 is the
>> >"raise".
>> >
>> >Richard
>> >
>> >
>> >"Jaap W. van Dijk" wrote:
>> >>
>> >> Why is it not correct? From an old posting in this newsgroup
>> >> (1999/10/25):
>> >>
>> >> create or replace package x as
>> >> procedure x1;
>> >> procedure x2;
>> >> end;
>> >> /
>> >>
>> >> create or replace package body x as
>> >> procedure x1 is
>> >> begin
>> >> x.x2;
>> >> end;
>> >> procedure x2 is
>> >> vx varchar2(4000);
>> >> vz varchar2(4000);
>> >> begin
>> >> raise_application_error(-20000,'Erreur',true);
>> >> exception when others then
>> >> vx := dbms_utility.format_Error_stack;
>> >> vz := dbms_utility.format_call_stack;
>> >> dbms_output.put_line('ERROR');
>> >> dbms_output.put_line('----Error stack----');
>> >> if vx is null then
>> >> dbms_output.put_line('vx is empty');
>> >> else
>> >> dbms_output.put_line('vx length is '||length(vx));
>> >> end if;
>> >> dbms_output.put_line(vx);
>> >> dbms_output.put_line('----Call stack----');
>> >> if vz is null then
>> >> dbms_output.put_line('vz is empty');
>> >> else
>> >> dbms_output.put_line('vz length is '||length(vz));
>> >> end if;
>> >> dbms_output.put_line(vz);
>> >> raise;
>> >> end;
>> >> end;
>> >> /
>> >>
>> >> set serveroutput on size 20000
>> >>
>> >> begin
>> >> x.x1;
>> >> end;
>> >> /
>> >> ERROR
>> >> ----Error stack----
>> >> vx length is 18
>> >> ORA-20000: Erreur
>> >>
>> >> ----Call stack----
>> >> vz length is 210
>> >> ----- PL/SQL Call Stack -----
>> >> object line object
>> >> handle number name
>> >> c4a0d2b8 13 package body NTC_ADMIN2.X
>> >> c4a0d2b8 4 package body NTC_ADMIN2.X
>> >> c5007168 2 anonymous block
>> >>
>> >> begin
>> >> *
>> >> ERROR at line 1:
>> >> ORA-20000: Erreur
>> >> ORA-06512: at "NTC_ADMIN2.X", line 29
>> >> ORA-06512: at "NTC_ADMIN2.X", line 4
>> >> ORA-06512: at line 2
>> >>
>> >> SQL>
>> >>
>> >> Nice, isn't it?
>> >>
>> >> Jaap.
>> >>
>> >> On Wed, 24 Apr 2002 17:31:05 +0400, "Vasily Poushko"
>> >> <vasily_at_genesyslab.ru> wrote:
>> >>
>> >> >Your answer is not correct.
>> >> >Please check it by yourself.
>> >> >
>> >> >"Sunil" <sunil_franklin_at_hotmail.com> wrote in message
>> >> >news:diyx8.4$Cv2.110_at_news.oracle.com...
>> >> >> Will 'format_call_stack' help. It gives you the line number .
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >> "Vasily Poushko" <vasily_at_genesyslab.ru> wrote in message
>> >> >> news:aa6aar$hgi$1_at_octopus.co.ru...
>> >> >> > How to get current program line number in exception?
>> >> >> >
>> >> >> > Hello. I'd like to get current program line number, where raised
>> >> >> exception.
>> >> >> >
>> >> >> > My code is:
>> >> >> > create or replace procedure qqq
>> >> >> > as
>> >> >> > n varchar2(1) := '12';
>> >> >> > begin
>> >> >> > null;
>> >> >> > exception when others
>> >> >> > dbms_out.put_line(sqlerrm);
>> >> >> > end;
>> >> >> > /
>> >> >> >
>> >> >> > execute qqq;
>> >> >> >
>> >> >> > output will be:
>> >> >> > ORA-06502: PL/SQL: numeric or value error: character string buffer too
>> >> >> small
>> >> >> >
>> >> >> > but I would like to get:
>> >> >> > ORA-06502: PL/SQL: numeric or value error: character string buffer too
>> >> >> small
>> >> >> > ORA-06512: at "SCOTT.QQQ", line 2
>> >> >> > ORA-06512: at line 2
>> >> >> >
>> >> >> > How can I do this?
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >>
>> >> >>
>> >> >
>> >> >
>> >
>
Received on Thu Apr 25 2002 - 15:20:52 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US