adspace


How to create a menu in sqlplus or pl/sql?

Answer Posted / Naveen Chand

Creating a menu in SQL*Plus or PL/SQL involves creating a stored procedure that displays options and calls other procedures based on user input. Here's a simple example:

```plsql
CREATE OR REPLACE PROCEDURE my_menu AS
option NUMBER;
BEGIN
DBMS_OUTPUT.PUT_LINE('Menu');
DBMS_OUTPUT.PUT_LINE('1 - Option A');
DBMS_OUTPUT.PUT_LINE('2 - Option B');
DBMS_OUTPUT.PUT_LINE('3 - Exit');
DBMS_OUTPUT.FLUSH;
COMMIT;

SELECT count(*) INTO option FROM dual WHERE TRUE;
IF option = 1 THEN
my_procedure_a;
ELSIF option = 2 THEN
my_procedure_b;
END IF;
END my_menu;
```

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is dbms? : Sql dba

1069


what are all the common sql function? : Sql dba

1141


Can delete statement be rollbacked?

1065


how many tables will create when we create table, what are they? : Sql dba

1154


If a cursor is open, how can we find in a pl/sql block?

1252


define sql insert statement ? : Sql dba

1108


What is the current version of postgresql?

1188


how to use regular expression in pattern match conditions? : Sql dba

1125


what are the advantages of sql ? : Sql dba

1153


What is the best sql course?

1062


Is inner join faster than left join?

1287


What is your daily office routine?

2351


Hi am new to PLSQL & facing problems in writing code like in SP, Functions, so any one having some SP coding with in depth explanation please share with me my Email ID suvarnaatsuvarna@rediffmail.com Or taking tanning on this please do contact me

2099


Can we use distinct and group by together?

1146


what is collation? : Sql dba

1242