Re: if else logic in SQLPlus scripts
Date: Fri, 20 Sep 2002 19:53:36 -0400
Message-ID: <amgcqo$i8r$1_at_nntp-m01.news.aol.com>
[Quoted] Technically speaking, the example shown is a PL/SQL block within SQLPLUS. :-))
SQLPLUS does not have any if/else support. As Daniel has shown, a PL/SQL block or if you prefer, database procedures will do this for you. None-the-less, you can accomplish if/else using the same sqlplus interface.
Kevin
"Daniel Morgan" <dmorgan_at_exesolutions.com> wrote in message
news:3D8B8AF1.EC93ACF6_at_exesolutions.com...
> Steve Mitchell wrote:
>
> > I know I saw a treatment of this someplace on the web, but I cannot find
it
> > now that I look for it.
> >
> > I would like to do some simple if/then/else logic from within my SQL
plus
> > scripts.
> >
> > Does anybody have any examples of this?
> >
> > Thanks.
> >
> > --steve
>
> SET SERVEROUTPUT ON
>
> DECLARE
>
> i PLS_INTEGER;
>
> BEGIN
> SELECT COUNT(*)
> INTO i
> FROM all_tables;
>
> IF i > 100 THEN
> DBMS_OUTPUT.PUT_LINE('There Are More Than 100 Tables');
> ELSE
> DBMS_OUTPUT.PUT_LINE('There Are Less Than 100 Tables');
> END IF;
> END;
> /
>
> Daniel Morgan
>
Received on Sat Sep 21 2002 - 01:53:36 CEST
