Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Newbie Question about USER Input
On Sat, 19 Oct 2002 16:00:19 GMT, "news.verizon.net" <never_at_nope.com>
wrote:
>To all,
> I would like to create a procedure that gets a value from the user and
>uses that value in an IF-THEN-ELSE statement.
>
>set serveroutput on;
>
>declare
> user_x char(1);
>begin
> &user_x;
> Upper('user_x');
>
> if user_x = 'A' then
> dbms_output.put_line('A');
> elsif user_x = 'B' then
> dbms_output.put_line('B');
> else
> dbms_output.put_line('Bad selection');
>End;
>/
>
You are not creating a procedure but an anonymous block (which is something completely different.
Your code needs to read
set serveroutput on;
>
declare
user_y char(1);
begin
select upper('&user_x') into user_y from dual; if user_y = 'A' then dbms_output.put_line('A'); elsif user_y = 'B' then dbms_output.put_line('B'); else dbms_output.put_line('Bad selection');End;
Regards
Sybrand Bakker, Senior Oracle DBA
To reply remove -verwijderdit from my e-mail address Received on Sat Oct 19 2002 - 11:51:17 CDT