带有“&”特殊字符的 Oracle 查询
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5545101/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Oracle Query with "&" special character
提问by MikeTWebb
I have an Oracle query that is blowing up when I have an "&D" in the where statement
我有一个 Oracle 查询,当我在 where 语句中有一个“&D”时它会爆炸
select <field> from <table> where field = 'ABC&D';
The Oracle Variable window pops up asking for a value for :D.
弹出 Oracle 变量窗口,要求输入 :D 的值。
Any ideas?
有任何想法吗?
回答by DCookie
Turn off variable substitution via:
通过以下方式关闭变量替换:
set define off
Then run your query. SQL*Plus is interpreting the &D as a runtime substitution variable.
然后运行您的查询。SQL*Plus 将 &D 解释为运行时替换变量。
回答by Tommi
Another option, if you do not wish to use SET
commands, is to use concatenation:
如果您不想使用SET
命令,另一种选择是使用串联:
select <field> from <table> where field = 'ABC' || '&' || 'D';