Search Oracle Blogs

List of Blogs maintained by Paweł Barut.


Tuesday, October 09, 2007

Comments in SQL*Plus

This Warning from Eddie Awad remind me of problem with comments I've had some time ago. I've prepared an script that was intended to run in sqlplus. Then I've extensively tested it, and as a last step, I've commented it. And ... did not test again. When this script was run on production caused errors. The problem was in the way that sqlplus interpret comments.
Example:
SQL> select * from dual;

D
-
X
runs fine, while this:
SQL> select * from dual; -- some comments
stops at second line waiting for input:
SQL> select * from dual; -- some comment
  2 
It was really unpleasant experience.

Cheers, Paweł

4 comments:

Kris Rice said...

In case you didn't know, the issue is the first - is treated as a continuation. So, plus thinks there's more coming on the next line.

Paweł Barut said...

Yes, I know this.
But it was a big surprise that adding comment at end of line caused this behavior.

Eddie Awad said...

The same thing happens with the slash and asterisk style comment:

SQL> select * from dual; /* some comment */
2

Anonymous said...

Hi,

This way it's not problematic:

SQL> select * from dual -- check this
2 /

IR

 

Copyright © Paweł Barut
Printing from DOS to USB Printer