You could (ab)use substitution variables:
set termout off
column var3_path new_value var3_path
select case
when '&var3' = 'true' then './oracle/myOthersqlfile.sql &&varA &&varB'
else '/dev/null'
end as var3_path
from dual;
set termout on
@&var3_path
The query between the set termout
commands - which just hide the output of the query - uses a case expression to pick either your real file path or a dummy file; I've used /dev/null, but you could have a 'no-op' file of your own that does nothing if that's clearer. The query gives the result of that the alias var3_path
. The new_value
line before it turns that into a substitution variable. The @
then expands that variable.
So if var3
is 'true' then that runs:
@./oracle/myOthersqlfile.sql &&varA &&varB
(or, actually, with the varA
and varB
variables already replaced with their actual values) and if it is false it runs:
@/dev/null
which does nothing, silently.
You can set verify on
around that code to see when and where substitution is happening.