Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to escape ampersand in TOAD?

Tags:

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?

like image 899
Utham Radipe Avatar asked Sep 11 '13 07:09

Utham Radipe


People also ask

How do you escape ampersand in SQL query?

If you set escape on, it uses an esape using the backslash. So, backslash ampersand will show you an ampersand. Hope this helps.

How do I escape special characters in Oracle?

Use braces to escape a string of characters or symbols. Everything within a set of braces in considered part of the escape sequence. When you use braces to escape a single character, the escaped character becomes a separate token in the query. Use the backslash character to escape a single character or symbol.

How do you do set define off in Toad?

SET DEFINE OFF is a script function so you need to use F5, not F9 to execute. A couple of us are using TOAD v10 while the rest of the company is using TOAD v9.

How do I escape special characters in SQL Developer?

Use the backslash character to escape a single character or symbol. Only the character immediately following the backslash is escaped.


1 Answers

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; 
like image 65
Andrea Avatar answered Sep 22 '22 20:09

Andrea