1.5.1 An English letter follows closely in comment symbol '/*'
In SQL*Plus, it will lead the SQL statement before the comment to be executed twice. For example, the script file “test.sql” includes follow SQL statements:
select 'aaa' from dual;
/*abc*/
select 'bbb' from dual;
We just want the statement ‘select 'aaa' from dual;’ to be executed once. However, we will get another result:
SQL> @c:test.sql
'AA
---
aaa
'AA
---
aaa
'BB
---
bbb
As you can see, the statement were executed twice.
This bug would not impact PL/SQL developer.
And this is the correct script (there is a blank char between ‘/*’ and ‘abc’):
select 'aaa' from dual;
/* abc */
select 'bbb' from dual;
The right result:
SQL> @c:test.sql
'AA
---
aaa
'BB
---
bbb
1.5.2 Commends follow a SQL statement
If a comment follows a SQL statement (the comments including ‘--’ mode and ‘/**/’ mode), this statement will be treated as comments, and will not be executed. For example, here a ‘test.sql’ script:
select 'aaa' from dual; --aaa
select 'bbb' from dual;
You will get this result when execute it:
SQL> @c:test.sql
'BB
---
bbb
Noted, the first SQL statement was not executed, because it was followed by a comments with ‘--’.
And, if the comment was placed in another line follow closely the SQL statement, it will also raise this bug:
select 'aaa' from dual;
--aaa
select 'bbb' from dual;
Execute the script:
SQL> @c:test.sql
'BB
---
bbb
This bug impact both SQL*Plus and PL/SQL developer.
And this is the correct script:
-- aaa
select 'aaa' from dual;
select 'bbb' from dual;
The right result:
SQL> @c:test.sql
'AA
---
aaa
'BB
---
bbb
1.5.3 Commends following a SQL statement, followed by another SQL statement closely
If a commend follows a SQL statement, and it was followed by another SQL statement closely. It will lead to a execution error. For example, this is the script:
select 'aaa' from dual; --aaa
select 'bbb' from dual;
Execute the script:
SQL> @c:test.sql
select 'aaa' from dual; --aaa
*
ERROR at line 1:
ORA-00911: invalid character
This bug will ignore the comments between them. For example, this is the script:
select 'aaa' from dual;--aaa
/* abc */
select 'bbb' from dual;
It will still raise the error:
SQL> @c:test.sql
select 'aaa' from dual;--aaa
*
ERROR at line 1:
ORA-00911: invalid character
This bug impact both SQL*Plus and PL/SQL developer.
And this is the correct script:
-- aaa
select 'aaa' from dual;
select 'bbb' from dual;
The right result:
SQL> @c:test.sql
'AA
---
aaa
'BB
---
bbb
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/60217/viewspace-889000/ ,如需转载,请注明出处,否则将追究法律责任。