139

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,

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?

RajSanpui
  • 11,556
  • 32
  • 79
  • 146
Janek Bogucki
  • 5,033
  • 3
  • 30
  • 40
  • 1
    That's strange, when I attempted to run a query exactly like that in SQL developer 2.1 I did not get the replacement variable window? (And my defines are most certainly set to on) – wasatz Feb 25 '10 at 12:55

5 Answers5

228

Call this before the query:

set define off;

Alternatively, hacky:

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

From Tuning SQL*Plus:

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

Álvaro González
  • 142,137
  • 41
  • 261
  • 360
Nick Craver
  • 623,446
  • 136
  • 1,297
  • 1,155
16

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

diederikh
  • 25,221
  • 5
  • 36
  • 49
1

this will work as you asked without 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';
Nikhil S
  • 3,786
  • 4
  • 18
  • 32
0

If you use liquibase to run sql file, it will not give error. But for sql developer use this set define off; before ur sql sode

Chamith
  • 69
  • 10
-3

set scan off; Above command also works.

  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post - you can always comment on your own posts, and once you earn sufficient reputation you will be able to comment on any post. If you have a related but different question, ask a new question referencing this one if it will help provide context. – Rohan Khude Aug 08 '16 at 07:36