Skip to content

Instantly share code, notes, and snippets.

@foobarbaz-pl
Last active January 16, 2018 09:49
Show Gist options
  • Save foobarbaz-pl/e2f6644dbd0e07559b290458a8cb4571 to your computer and use it in GitHub Desktop.
Save foobarbaz-pl/e2f6644dbd0e07559b290458a8cb4571 to your computer and use it in GitHub Desktop.
SQL*Plus Conditional Script Execution
-- activate substitution variables
set define on
-- suppress echo for substitution variables
set verify off
-- activate stdout
set serveroutput on
define _IF_MASTER_INSTANCE="--"
col master_instance new_value _IF_MASTER_INSTANCE noprint
select case
when sys_context('USERENV',
'DB_NAME') = 'ABCD' then
'script.sql'
else
'noop.sql' -- empty
end master_instance
from dual
/
@&_IF_MASTER_INSTANCE
undefine _IF_MASTER_INSTANCE
col master_instance clear
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment