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



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

Answer / 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

More SQL PLSQL Interview Questions

How does one use sql*loader to load images, sound clips and documents? : aql loader

1 Answers  


What is dynamic SQl and how you will create and execute dynamic sql?

2 Answers   TCS,


How do I run a sql query?

1 Answers  


explain the difference between bool, tinyint and bit. : Sql dba

1 Answers  


What is a trigger word?

1 Answers  


There is a sequence with min value 100. I want to alter this sequence to min value as 101. If the table has already data in the sequence column as 100,101,102... Is it possible to do so ?

4 Answers   IBM,


Hi Everyone, How to get fist and last record from a table in oracle? Thanks in advance

13 Answers   IBM,


What is a join query?

1 Answers  


What is the importance of sqlcode and sqlerrm?

1 Answers  


What are character functions in sql?

1 Answers  


What are literals in sql server?

1 Answers  


Is oracle sql free?

1 Answers  


Categories