How do I ignore ampersands in a SQL script running from SQL Plus?
I have a SQL script that creates a package with a comment containing an ampersand (&). When I run the script from SQL Plus, I am prompted to enter a substitute value for the string starting with &. How do I disable this feature so that SQL Plus ignores the ampersand?
Solution 1:
This may work for you:
set define off
Otherwise the ampersand needs to be at the end of a string,
'StackOverflow &' || ' you'
EDIT: I was click-happy when saving... This was referenced from a blog.
Solution 2:
If you sometimes use substitution variables you might not want to turn define off. In these cases you could convert the ampersand from its numeric equivalent as in || Chr(38) ||
or append it as a single character as in || '&' ||
.
Solution 3:
I resolved with the code below:
set escape on
and put a \ beside & in the left 'value_\&_intert'
Att