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

Home -> Community -> Usenet -> c.d.o.server -> Re: SQL*Plus: can variables be used for control of execution?

Re: SQL*Plus: can variables be used for control of execution?

From: Anurag Varma <avdbi_at_hotmail.com>
Date: Tue, 30 Mar 2004 15:14:23 GMT
Message-ID: <j9gac.28138$Td3.17906@nwrddc02.gnilink.net>

"Randi W" <randiwolner_at_hotmail.com> wrote in message news:c4bal9$f3p$1_at_services.kq.no...
> I run Oracle v.8.1.7, and I am making a script to be run in SQL*Plus several
> times.
> This script should be run by one specific user logged on, and I would like
> to add some functionality to check whether the person starting the script is
> logged on as the user I want her to be, otherwise do not run the commands.
>
> It seems to be possible to use variables in SQL*Plus scripts, so I can
> probably put the name of the current user into a variable. But I would like
> to terminate the script (EXIT) if the content of that variable is not
> identical to one specific value - something like:
> IF VAR1 <> 'SUP'
> EXIT;
> ELSE
> .
> .
> Is it possible in any way to get this functionality into a SQL*Plus script?
>
> Thanks for any help on this,
> Randi W
>
>
>

Randi,

You can try something like this:

whenever sqlerror exit failure

begin

   if (user != 'BUBBA') then
     raise_application_error(-20001,'ERROR: You are not Bubba?');    end if;
end;
/

whenever sqlerror continue

select 'ABCD' from dual;

Anurag Received on Tue Mar 30 2004 - 09:14:23 CST

Original text of this message

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