Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: How to put if statement with Accept value ???
> -----Original Message-----
> From: Andrea Oracle [mailto:andreaoracle_at_yahoo.com]
>
> How to do a if statement with Accept? Like I first
> prompt user for a value, "Accept var prompt ...", then
> based on the value I got, do differenct things.
> (Oracle 815 on Sun)
Since you mention the Accept command, I assume you are using SQL*Plus. If so, you can use the substitution variable set by the Accept statement in a PL/SQL block, like so:
SQL> accept x char prompt "Delete Table (Y/N)? "
Delete Table (Y/N)? N
SQL> begin
2 if '&x' = 'Y' 3 then 4 execute immediate 'drop table t' ; 5 end if ; 6 end ; 7 /
Procédure PL/SQL terminée avec succès. Received on Tue Oct 02 2001 - 17:28:26 CDT
![]() |
![]() |