Re: Conditional logic in a main SQLPLUS script file

From: Niall Litchfield <niall.litchfield_at_gmail.com>
Date: Wed, 5 Jan 2011 11:17:23 +0000
Message-ID: <AANLkTin3s9Ka5+Gn0hVwU5o+bzd4eYeUWBXoF16btK-__at_mail.gmail.com>



Shell scripting? Perl?

On Wed, Jan 5, 2011 at 11:12 AM, Dylan Farre <dylan.farre_at_gmail.com> wrote:

> I am looking for a way to implement conditional logic in a main sql script
> file, that calls other script files.
>
> In PLSQL, this is easy using regular IF THEN ELSE statements. It is even
> easy to add or remove blocks of PLSQL from compiled objects (using
> pre-compiler directives). For example, in a stored procedure, by including
> something like this:
>
> CREATE OR REPLACE PROCEDURE ZZZ AS
> ..
>
> BEGIN
>
> $IF packageA.option_1 = 1 $THEN
> do_something();
> $ELSE
> do_something_else();
> $END
>
> END;
> /
>
> Which will create two different versions of procedure ZZZ, depending on the
> value of packageA.option_1. Sometimes this is handy, if most of the code
> in procedure ZZZ is the same and there is only a small difference required
> under certain circumstances.
>
> But what I want to do is something like this:
>
> _at_script_0.sql
> $IF packageA.option_1 = 1 $THEN
> _at_script_1.sql
> $ELSE
> _at_script_2.sql
> $END
> ...
>
> I understand that this does not work, but is there a another way to achieve
> what I am trying to do here?
>
> Any suggestions? Thanks.
>

-- 
Niall Litchfield
Oracle DBA
http://www.orawin.info

--
http://www.freelists.org/webpage/oracle-l
Received on Wed Jan 05 2011 - 05:17:23 CST

Original text of this message