Skip to main content

Working around the vile Ampersand(&) in SQL

I recently had the misfortune of having to insert several URLs into an Oracle database. This trivial activity was made more challenging by having to deal with URL parameters, which were delimitated with an ampersand (&).

Inserting URL data is usually pretty easy.


But any operation I try where the URL has an ampersand, SQL Developer prompts me for an input value:


That's not what I want at all!

Here's a couple different ways to get around this:


  • SET DEFINE OFF; Works if you aren't going to define any variables in the session


  • SET ESCAPE ON;  AND add a forward slash (\) in front of the ampersand; 
  • String concatenation is my least fav, but it works in a pinch. 







NOTE: Application Express avoids this issue completely by using colons instead of ampersands.

Comments