Re: Conditional logic in a main SQLPLUS script file

From: Mark Brinsmead <pythianbrinsmead_at_gmail.com>
Date: Sat, 8 Jan 2011 22:20:06 -0500
Message-ID: <AANLkTimWhurnWWi_kG1ob+noXeyaKqyq1Nr-iOE1zDuT_at_mail.gmail.com>



/bin/cpp, maybe? The C pre-processor. You can also use #include and any other preprocessor directive. You are not limited to #ifdef

On Wed, Jan 5, 2011 at 6:17 AM, Niall Litchfield <niall.litchfield_at_gmail.com
> wrote:

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

-- 
Cheers,
-- Mark Brinsmead
   Senior DBA,
   The Pythian Group
   http://www.pythian.com/blogs

--
http://www.freelists.org/webpage/oracle-l
Received on Sat Jan 08 2011 - 21:20:06 CST

Original text of this message