Escape ampersand in PL/SQL Developer

Ray Booysen picture Ray Booysen · Aug 18, 2011 · Viewed 69.8k times · Source

I'm trying a simple INSERT statement against an Oracle database. One of the values is a VARCHAR2 field and the insert statement contains an ampersand. How do I do this? I've tried the following methods:

  1. Escape the & as \& with set escape on
  2. set scan off (this causes an ORA-00922 missing or invalid option error)
  3. set define off (this causes an ORA-00922 missing or invalid option error)

Any other ideas?

Answer

Ray Booysen picture Ray Booysen · Aug 18, 2011

How I solved it is escaping the & with another &.

For example:

INSERT INTO Foo (Bar) VALUES ('Up && Away');

Works nicely. Thanks for all the help