How to escape ampersand in TOAD?

强颜欢笑 提交于 2019-11-29 06:07:58

问题


When I try to insert a value which has '&' in TOAD I get a prompt for a substitution variable.

So when I try:

insert into x values('hello & world'); 

it throws a prompt for substituting the variable 'world'.

I have tried right clicking in the editor and disabling prompt for substitution variables but this seems to work only for Execute Statement (F9) It doesn't work for Execute as script(F5).

I am also aware of using chr(38) like:

insert into x values('hello '||chr(38)||'world');

but I do not want this. Is there something else that will help me run the script?


回答1:


Try putting set define off at the beginning of your script. It should work with F5:

set define off;
insert into x values('hello & world'); 
set define on;



回答2:


set define off doesn't work in TOAD just in sqlplus.

You can disable substitution variable support by right-clicking in the Editor and unchecking the “Prompt for Substitution Variables” item. It works with F9 execution but not with F5 (script) execution. With F5 you need to add "set define off" in the first line then launch with F5!! (hope this help it was very hard to find for me)




回答3:


In TOAD version 12.120.39 Right click in Editor and Click in Substitution Variable Prompting and select none

This worked for me.



来源:https://stackoverflow.com/questions/18735499/how-to-escape-ampersand-in-toad

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