On the move:

I'm currently moving the following to their own blogs: Unix, HTML for Blogs, Perl & Java.
The links are on the left side.

Friday, June 6, 2008

Creating a Simple Menu with SQL+


This query does the following: Clear the screen before prompting for values. After the user selects an option, the terminal is turned off so the decode is behind the scenes. It's then turned back on. The program is run using '@'. The Accept is needed afterwards to get this query to stop and allow them to view the screen. At the end, this code is called again. You'll need to Ctrl+C to get out of this loop.
Clear Screen
Prompt
Prompt +-----------------------------+
Prompt | M y T a b l e s |
Prompt +-----------------------------+
Prompt | |
Prompt | 1. Insert Data |
Prompt | 2. View Data |
Prompt +-----------------------------+
Prompt
Accept Report Prompt 'Please Enter Choice: '
Clear Screen

Set Verify Off
Set Term Off
-- Set up an amper variable with the program name from the decode
Column DecodeReport New_Value NewReport

Select Decode (&Report, '1', 'iexample', -- insert into table
'2', 'sexample', -- Select all recs from table
'mexample' -- if not valid, rerun
) As DecodeReport
From Dual;

Set Term On Feedback Off

@&NewReport -- run the code selected in the decode

-- Accept needed to hold on screen
Accept Holder Prompt 'Press Enter to continue...'

Undefine Report NewReport Holder

@mExample -- when done, rerun this menu
-- (Ctrl+C to escape)

No comments:

Post a Comment