Name

ACCEPT

Synopsis

The ACCEPT command gets input from a user. It causes SQL*Plus to display a prompt and wait for the user to type something in response. You can read about ACCEPT in Chapter 8 and in Chapter 11.

Syntax

ACC[EPT] variable [NUM[BER] | CHAR | DATE | BINARY_FLOAT | BINARY_DOUBLE]
        [FOR[MAT] format_specification]
        [DEF[AULT] default_value]
        [PROMPT prompt_text | NOPR[OMPT]]
        [HIDE]

Parameters

ACC[EPT]

Is the command, which may be abbreviated ACC.

variable

Is the variable you want to define. Don't include leading ampersands. If your script uses &table_name for a substitution variable, you should use table_name here.

NUM[BER] | CHAR | DATE | BINARY_FLOAT | BINARY_DOUBLE

Is the type of data you are after. The default is CHAR, which allows the user to type in anything as a response. Use NUMBER, BINARY_FLOAT, or BINARY_DOUBLE to force the user to enter a number. Use DATE when you want a date.

FOR[MAT] format_specification

Is a format specification, which may optionally be enclosed in quotation marks. ACCEPT rejects any input that doesn't conform to the specification. An error message is displayed and the prompt is reissued. Specifying a format makes the most sense when dealing with numeric and date data, and SQL*Plus is somewhat loose in enforcing the format. Chapter 11 delves into this aspect of the ACCEPT command in detail. Format elements are described in Appendix B.

DEF[AULT] default_value

Specifies a default value to assign to the variable. This is used if the user bypasses the prompt ...

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.