Name

SET ESCAPE

Synopsis

The ESCAPE setting specifies the character used to escape the substitution variable prefix.

Syntax

SET ESC[APE] {OFF | ON | escape_char}

Parameters

SET ESC[APE]

Is the command, which may be abbreviated SET ESC.

OFF

Turns the escape feature off completely. SQL*Plus will not recognize any character as an escape character. This is the default setting.

ON

Enables the escape feature and resets the escape character back to the default value, a backslash (\).

escape_char

Is the new escape character. By default, this is a backslash.

Examples

You use the escape character when you want to place an ampersand in a command and you don't want that ampersand interpreted as a substitution variable prefix character. The following example shows a case where this can be a problem:

SQL> SELECT 'Matt & Joe Williams' FROM dual;
Enter value for joe:

The ampersand in front of the word "Joe" causes SQL*Plus to interpret it as a substitution variable name. To work around this behavior, you can turn the escape feature on and precede the ampersand with a backslash. Here's an example:

SQL> SET ESCAPE ON
SQL> SELECT 'Matt \& Joe Williams' FROM dual;
'MATT&JOEWILLIAMS'
-------------------
Matt & Joe Williams

You can use the SET ESCAPE command to change the escape character to something other than a backslash.

Get Oracle SQL*Plus: The Definitive Guide, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.