ORA-00911: Invalid Character via ODBC, Adhoc SQL - within comments?

点点圈 提交于 2019-12-12 01:56:14

问题


When executing the following statement (as an example) I get an error ORA-00911: Invalid character

"/* it is the end of the world */\nSELECT 1 FROM MyTable;"

Other comments are fine. What's the problem?

We use comments to annotate our Ad-Hoc SQL.

(Oracle11gR2, Windows )

This does not happen via SQL Plus or SQL Developer.


回答1:


If a comment includes the whole word end then the Oracle driver (or server) appears to be interpreting this badly. If you remove the end word within the comment, the statement executes correctly.

I think this is because it doesn't expect a semi-colon after experiencing an 'end' directive (even though it shouldn't be parsing a comment).

The following statement executes without issue and returns 7.

/* end */\nSELECT 7 FROM MyTable 

The following statement raises ORA-00911

/* end */\nSELECT 6 FROM MyTable;

The following statement returns 5

/**/\nSELECT 5 FROM MyTable;

It's likely that Oracle parses the comment because that's how it applies join operation/optimization 'hints'.



来源:https://stackoverflow.com/questions/27062730/ora-00911-invalid-character-via-odbc-adhoc-sql-within-comments

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!