1-10. Ignoring Substitution Variables

Problem

You want to execute a script in SQL*Plus that contains elements that appear to be substitution variables, but you do not intend them to be substitution variables. You want the interpreter to ignore them instead of prompting the user for input.

Solution #1

One solution is to precede the & character with an escape character. The escape character tells SQL*Plus that what follows is not intended to be a variable reference.

In the following code, an escape character is used to tell SQL*Plus to ignore the & character when it is encountered and to treat “& Receiving” as simple text within a string:

SQL> SET ESCAPE '\' SQL> INSERT INTO DEPARTMENTS VALUES(   2  departments_seq.nextval,   3  'Shipping \& Receiving', ...

Get Oracle and PL/SQL Recipes: A Problem-Solution Approach 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.