Thursday, 10 November 2011

SQL*Plus ACCEPT Command

The ACCEPT command allows a variable to be created and a value that's entered to be withheld in it this variable can then be used in the construction of SQL.

ACCEPT is used often in a file of commands. There are several advantages arising from the use of the ACCEPT to define the substitution of variables:

- The types of data can be verified
- Prompts may be more explanatory
- Response Values can be hidden

The command syntax is:
ACC [EPT] variable [NUMBER/CHAR] [PROMPT/NOPROMPT ' text '] [HIDE]
 
Examples

SQL > ACCEPT SALARY NUMBER PROMPT ' Salary amount: '
Salary amount: 60,000

SQL > ACCEPT PASSWORD CHAR PROMPT ' Password: ' HIDE
Password:

SQL > ACCEPT COMM NUMBER NOPROMPT
700

SQL > DEFINE

DEFINE SALARY = 60,000 (NUMBER)
DEFINE PASSWORD = "Abc1234##" (CHAR)
DEFINE COMM = 700 (NUMBER)

No comments:

Post a Comment