Do Comments Throw Off Error Backtrace? No!

Just received this feedback on an Oracle Magazine article:
I’ve just started using DBMS_UTILITY.FORMAT_ERROR_BACKTRACE and it’s a great utility when the code contains no comments, but unless I’m missing something it’s not terribly useful with regard to pinpointing the exact line number when the code contains comments.
Now, I must confess that I am tempted to respond with such questions along these lines:
Did you try it out? That's the best way to learn!
But I am always looking for another reason to post on my blog and add to the LiveSQL repository. So that's what I am doing! :-)

The answer is quite straightforward:

Comments do not interfere with "pinpointing the exact line number" on which the error was raised.

But I bet you want proof, so let's get down to business.

I create a procedure with comments and a RAISE statement:

CREATE OR REPLACE PROCEDURE comments_throw_off_line# 
Here's my header 
Blah blah blah 
   DBMS_OUTPUT.put_line ('wow!'); 
   And here's another comment because I really love 
   to fill my code with meaningless comments! 
   RAISE PROGRAM_ERROR; /* This is line 14 */ 
      DBMS_OUTPUT.put_line (DBMS_UTILITY.format_error_backtrace); 

I run the procedure and see this output:


ORA-06512: at "COMMENTS_THROW_OFF_LINE#", line 14

So, there's your answer.

Next question? :-)


Popular posts from this blog

Table Functions, Part 1: Introduction and Exploration

Recommendations for unit testing PL/SQL programs

The future of Oracle PL/SQL: some thoughts on Sten Vesterli's thoughts