Conditional logic in a main SQLPLUS script file

From: Dylan Farre <>
Date: Wed, 5 Jan 2011 11:12:45 +0000
Message-ID: <>

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:


BEGIN   $IF packageA.option_1 = 1 $THEN

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:

$IF packageA.option_1 = 1 $THEN




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.

Received on Wed Jan 05 2011 - 05:12:45 CST

Original text of this message