Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to make SQL*Plus count comment and blank line numbers?

dariyooshJul 3 2013 — edited Jul 3 2013

Hi,

Parameter
Parameter value
Oracle versionEnterprise Edition Release 11.2.0.1.0 - 64bit
OSLinux Fedora Core 17 (X86_64)

I would like to know, is there any way to force SQL*Plus to provide the actual line number in the source file whenever there is an error? I often put at the first line of my script SET SQLBLANKLINES ON so that I may be able to put several consecutive blank lines lines in my code (I do this sometimes, when I find it to be appropriate in order to make my code more readable or to group a sequence of instructions which I believe make their logical link more understandable for the reader)

Now the problem is that SQL*Plus ignores these blank lines and whenever there is an error, the line number provided in the error message, doesn't correspond to the actual line number in the source file but it seems to be the last non blank line in the file.  Consider the following example:

SET SQLBLANKLINES ON;

DECLARE
    var PLS_INTEGER := 10;
BEGIN


   
    var := 20
END;
/

In the above code at line 9 (by counting also the blank lines) there is an error (no semicolon at the end of var := 20) but when I run the script in

SQL*Plus  here is the error message that I get


SQL> @myscript.sql;

END;

*

ERROR at line 8:

ORA-06550: line 8, column 1:

PLS-00103: Encountered the symbol "END" when expecting one of the following:

* & = - + ; < / > at in is mod remainder not rem

<an exponent (**)> <> or != or ~= >= <= <> and or like like2

like4 likec between || multiset member submultiset

The symbol ";" was substituted for "END" to continue.


SQL>


So as you can see the error message indicate that the error was found at the line 8 whereas in the file it is really at the line 9

As long as the number of lines in the script is limited, this may not be a problem and one can find rapidly the actual line number in the code raising the error but for a code including hundreds (or even thousands) of lines and with many comments and blank lines, finding the actual line number given by SQL*Plus error message becomes tricky.

So my question: Is there any way to make SQ*LPlus trace correctly the line numbers as they appear in the source file?

Thanks in advance,

Regards,

Dariyoosh

This post has been answered by Frank Kulash on Jul 3 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 31 2013
Added on Jul 3 2013
5 comments
1,044 views