Q:

PL/SQL Oracle 10g Ask user for input (other than substitution variable)

pseudo code:
declare
    n number(10);
begin
    dbms_output.put_line('Welcome to Oracle');
    dbms_output.put_line('1. Insert');
    dbms_output.put_line('2. Delete');
    dbms_output.put_line('Choose an option');

    n:=&choice;

    if(n=1)
        .....
        .....
    else
        ....
        ....
    end if;
end;

I am getting a problem here.  When I try to run it, it asks for '&choice' first and after that it shows the dbms_output.put_line() statements.
But I want to show choices first and then ask for user for their input.
sample output (how I want it):
 Welcome to Oracle
 1. Insert
 2. Delete
 Choose an option:
 Enter the value for choice:

so what is the solution for this? is there any other way to take input from user?
thanks in advance. 

A:

PL/SQL is not interactive, so you cannot do that in PL/SQL. 
Using & to prompt user for an input is a SQL*Plus command and not in PL/SQL. PL/SQL is executed inside the database engine and cannot access the terminal window or the GUI tool like SQL Developer etc.
Having said that, you could pass parameters.
For example,
SQL> SET serveroutput ON
SQL> DECLARE
  2    prompt_input NUMBER;
  3  BEGIN
  4    dbms_output.put_line('Welcome to Oracle');
  5    dbms_output.put_line('1. Insert');
  6    dbms_output.put_line('2. Delete');
  7    dbms_output.put_line('Choose an option');
  8    prompt_input := '&1';
  9    IF prompt_input = 1
 10    THEN
 11    dbms_output.put_line('You have selected '||prompt_input||' .Insert');
 12    ELSE
 13    dbms_output.put_line('You have selected '||prompt_input||' . Delete');
 14    END IF;
 15  END;
 16  /
Enter value for 1: 1
old   8:   prompt_input := '&1';
new   8:   prompt_input := '1';
Welcome to Oracle
1. Insert
2. Delete
Choose an option
You have selected 1 .Insert

PL/SQL procedure successfully completed.

SQL>

