Coments at the end of line in SQLPlus

Viewed 471

I checked that if I write a comment after the char of the end of a sentence (;), the instrucction is not run but also there are no error, like if all the line were a comment.

Example:

Insert into MI_TABLA
   (FIELD1, FIELD2, FIELD3, FIELD4, FIELD5)
 Values
   ( 311, 'TEST1', 'TEST1', 'TEST1', 1);

INSERT INTO MI_TABLA
   (FIELD1, FIELD2, FIELD3, FIELD4, FIELD5)
VALUES
   ( 312, 'TEST2', 'TEST2', 'TEST2', 1);--Comment that ignore all the line

INSERT INTO MI_TABLA
   (FIELD1, FIELD2, FIELD3, FIELD4, FIELD5)
VALUES
   ( 313, 'TEST3', 'TEST3', 'TEST3', 1);

COMMIT;

If I run this with SQLPlus over the Data Base, the resut is that only is inserted TEST1 and TEST3 but no TEST2. But the bad new is that do not show any error, and the output only show 2 inserts (There is two messages like this: 1 row created. and nothing more).

Any idea about the reason of this? Are there any way to do that SQLPlus do no ignore this line and works or at least it shows any error?

2 Answers

The semicolon (;) has to be the last character of the statement, or sql*plus will not recognize it as such. An easy fix would be to put the semicolon after the comment, although I would prefer to put the semicolon on a separate line.

After a lot of test and error I finally got a solution to my problem. I hope it can help any one with the same problem.

The solution was simple: writing next line at first line of the script or at the SQL prompt:

SET SQLBLANKLINES ON

I get an error when the sentence ends with a comment after the semicolon and also when the no ends with a semicolon.

Related