Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
607 views
in Technique[技术] by (71.8m points)

sql - How to escape ampersand in TOAD?

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...