Tuesday, October 13, 2009

sql on '&' character in Oracle

Escape ampersand (&) characters in SQL*Plus

When using SQL*Plus, the DEFINE setting can be changed to allow &'s (ampersands) to be used in text:


SET DEFINE ~
SELECT 'Lorel & Hardy' FROM dual;
Other methods:

Define an escape character:


SET ESCAPE '\'
SELECT '\&abc' FROM dual;
Don't scan for substitution variables:


SET SCAN OFF
SELECT '&ABC' x FROM dual;