Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: How to put if statement with Accept value ???

RE: How to put if statement with Accept value ???

From: Jacques Kilchoer <Jacques.Kilchoer_at_quest.com>
Date: Tue, 02 Oct 2001 15:28:26 -0700
Message-ID: <F001.0039FC2E.20011002154028@fatcity.com>

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

ancien   2 :    if '&x' = 'Y'
nouveau   2 :    if 'N' = 'Y'

Procédure PL/SQL terminée avec succès. Received on Tue Oct 02 2001 - 17:28:26 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US