12-6. Accepting User Input for Substitution Variables

Problem

You want to create a PL/SQL application that accepts user input from the keyboard. To test the input, you want to have Oracle SQL Developer prompt you for input.

Solution

Use an ampersand in front of a text string just like in SQL*Plus. Assign the resulting user variable to a PL/SQL variable, or use the value inline.

How It Works

Just as SQL*Plus treats the ampersand as a token to denote user input, Oracle SQL Developer does the same. When an ampersand is encountered, Oracle SQL Developer will display a pop-up box to prompt the user for the input. For example, type or copy and paste the following code into the SQL worksheet, and then select the Run Statement toolbar button.

DECLARE ...

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.