I used the same code, but instead of running the scripts in options 1, and 2, the script asks for this
This is the link I used: How to make a menu in SQLPlus or PL/SQL?
PROMPT 1: Make a sales invoice
PROMPT 2: Inquire a sales invoice
accept selection PROMPT "Enter option 1-2: "
set term off
column script new_value v_script --Q1. What's column script?
select case '&selection.' --from accept above
when '1' then '@test1.sql' --script to run when chosen option 1.
when '2' then '@test2.sql' --script to run when chosen option 2.
else '@FinalAssignment.sql' --this script
end as script --Q2. What script is this referring to?
from dual; --Q3. Don't know this
set term on
@&v_script. --Q4. What script is being ran here?
This is my output what I got
SQL> @myScript
1: Make a sales invoice
2: Inquire a sales invoice
Enter option 1-2: 1
Enter value for v_script: 1
SP2-0310: unable to open file "1.sql"
The name of my Script file is "myScript" so I think the menu should reload by itself if an invalid option is entered. However it is not doing so for some reason..
I dont get this, and also I want the code to run in a loop even when one script is executed , it should come back to menu and ask for another selection. If invalid option is entered again, it should come back to menu for the user to pick another selection.
My code with the Loop Included is here:
PROMPT 1: Make a sales invoice
PROMPT 2: Inquire a sales invoice
accept selection PROMPT "Enter option 1-2: "
set term off
LOOP
column script new_value v_script --Q1. What's column script?
select case '&selection' --from accept above
when '1' then @test1.sql --script to run when chosen option 1.
when '2' then @test2.sql --script to run when chosen option 2.
when '3' then @test3.sql
EXIT WHEN &selection = 4;
else '@myScript.sql' --this script
end as script --Q2. What script is this referring to?
from dual; --Q3. Don't know this
END LOOP;
set term on
@&v_script. --Q4. What script is being ran here?