Friday, March 18, 2016

How to insert an ampersand into an Oracle field


I was trying to insert a value into a varchar2 field.  The value contained an ampersand.  Something like "A&B Home Remodeling".  It kept giving me an error like &B was a variable.


What worked for me was storing it like this:
'A'||'&'||'B'


It like that much better.  I also saw suggestions to chr(38).  I did not try that, so I am not sure if it works, but I am guessing it would be very similar to what I did.  Something like:
'A'||chr(38)||'B'