Accept command in Oracle
In this section we will see how to use the Accept command in SQL Plus.
The ACCEPT command in SQL Plus is used to take the input from the user and then store in a variable. This variable can be used to substitute some value in the sql command. Usage of the ACCEPT command:
ACCEPT User input
ACC[EPT] variable [NUM[BER]|CHAR|DATE] [FORMAT format]
[DEFAULT default] [PROMPT text|NOPROMPT] [HIDE]
Following example shows how to use the Accept in SQLPlus.
SQL> select * from user where username='&user_name'
SQL> /
Enter value for user_name: Deepak
old 1: select username from user where username='&user_name'
new 1: select username from user where username='Deepak'
USERNAME
------------------------------
Deepak
1 row selected.
This way you can create you sql queries to generate the report, in which your user can input some values and based on that appropriate data is retrieved from database.
You can use SQL Plus to generate many types of reports. The accept command will be useful if you want your report to be generated based on the user input.
More Tutorials on roseindia.net for the topic Accept command in Oracle.If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.