如何使用“特立尼达和多巴哥”避免 Oracle SQL Developer 中的变量替换

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2333994/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 02:25:17  来源:igfitidea点击:

How to avoid variable substitution in Oracle SQL Developer with 'trinidad & tobago'

oracleoracle-sqldeveloper

提问by Janek Bogucki

When I try to execute this statement in Oracle SQL Developer 2.1 a dialog box "Enter Substitution Variable"pops up asking for a replacement value for TOBAGO,

当我尝试在 Oracle SQL Developer 2.1 中执行此语句时,会弹出一个对话框“输入替换变量”,要求为TOBAGO提供替换值,

update t set country = 'Trinidad and Tobago' where country = 'trinidad & tobago';

How can I avoid this without resorting to chr(38)or u'trinidad \0026 tobago'which both obscure the purpose of the statement?

我怎样才能避免这种情况而不诉诸于chr(38)u'trinidad \0026 tobago'两者都掩盖了声明的目的?

回答by Nick Craver

Call this before the query:

在查询之前调用它:

set define off;

Alternatively, hacky:

或者,hacky:

update t set country = 'Trinidad and Tobago' where country = 'trinidad &' || ' tobago';


From Tuning SQL*Plus:

调整 SQL*Plus 开始

SET DEFINE OFF disables the parsing of commands to replace substitution variables with their values.

SET DEFINE OFF 禁止解析命令以用它们的值替换替换变量。

回答by diederikh

In SQL*Plus putting SET DEFINE ?at the top of the script will normally solve this. Might work for Oracle SQL Developer as well.

在 SQL*Plus 中,放在SET DEFINE ?脚本顶部通常可以解决这个问题。也可能适用于 Oracle SQL Developer。

回答by nikhil sugandh

this will work as you asked without CHAR(38):

这将在没有 CHAR(38) 的情况下按照您的要求工作:

update t set country = 'Trinidad and Tobago' where country = 'trinidad & '|| 'tobago';

create table table99(col1 varchar(40));
insert into table99 values('Trinidad &' || '  Tobago');
insert into table99 values('Trinidad &' || '  Tobago');
insert into table99 values('Trinidad &' || '  Tobago');
insert into table99 values('Trinidad &' || '  Tobago');
SELECT * FROM table99;

update table99 set col1 = 'Trinidad and Tobago' where col1 = 'Trinidad &'||'  Tobago';

回答by Dinesh Garud

set scan off; Above command also works.

设置扫描关闭;上面的命令也有效。

回答by ufo2mstar

I was having some issue around this too. Something was starting up everytime I tried to setup a connection to any DB..

我也遇到了一些问题。每次我尝试建立与任何数据库的连接时,都会有一些东西启动..

What worked for me was removing any startup script that you might have configured!

对我有用的是删除您可能已配置的任何启动脚本!

i.e. Tools>Preferences...>Databaseand remove any file path that you have in the text box labeled "Filename for connection startup script"!

Tools>Preferences...>Database,删除标有“连接启动脚本的文件名”的文本框中的任何文件路径!