Oracle SQL - User-Friendly Prompting


User-friendly prompting uses a combination of the three SQL*Plus commands: PROMPT, PAUSE, and ACCEPT.

Normally, the newline character is a SQL*Plus command delimiter.

You can change that special meaning of the newline character by ending your command lines with a minus sign (-).

The following code shows how to use PROMPT, PAUSE, and ACCEPT

SQL> prompt This is a demonstration.
This is a demonstration.

SQL> pause Hit the [Enter] key...
Hit the [Enter] key...

SQL> accept x number -
> prompt "Please enter a value for x: "
Please enter a value for x: 42

SQL> define x
DEFINE X               =       42 (NUMBER)

The PROMPT command allows you to write text to the screen.

The PAUSE command allows you to suspend script execution.

The ACCEPT command gives you full control over the data type of the user-defined variable and the screen text prompting for a value.

Splitting commands over multiple lines by using the minus sign as an escape character is only for SQL*Plus commands, not for SQL commands.

Related Topic