How to create a menu in SQLPlus or PL/SQL?

Answer

Here is a SQL Plus script to do that:

prompt Please make a selection:
prompt 1: Do script a
prompt 2: Do script b
prompt 3: Do script c

accept selection prompt "Enter option 1-3: "

set term off

column script new_value v_script

select case '&selection.'
       when '1' then 'script_a'
       when '2' then 'script_b'
       when '3' then 'script_c'
       else 'menu'
       end as script
from dual;

set term on

@&v_script.

NB The 'menu' in the ELSE part of the case expression is the name of this script, so that it runs itself again when the user enters an invalid option.







 

All plsql Questions

Ask your interview questions on plsql

Write Your comment or Questions if you want the answers on plsql from plsql Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---