Skip to content

Instantly share code, notes, and snippets.

@foobarbaz-pl
Last active January 15, 2018 16:47
Show Gist options
  • Save foobarbaz-pl/72b7dcd85957381108c840f10c31e155 to your computer and use it in GitHub Desktop.
Save foobarbaz-pl/72b7dcd85957381108c840f10c31e155 to your computer and use it in GitHub Desktop.
PL/SQL Conditional Compilation
declare
l_sql varchar2(32767);
l_variables varchar2(1000) := '';
l_rac varchar2(50) := 'FALSE';
begin
if dbms_utility.is_cluster_database then
l_rac := 'TRUE';
end if;
l_variables := l_variables || 'RAC:' || l_rac || ',';
-- other conditional compilation flags goes here
l_variables := rtrim(l_variables,
',');
dbms_output.put_line(l_variables);
l_sql := q'[alter session set PLSQL_CCFLAGS=']' || l_variables || q'[']';
execute immediate l_sql;
end;
/
create function get_val return varchar2
$if not dbms_db_version.ver_le_10_2 $then
result_cache
$end;
as
begin
null;
$if $$RAC $then
-- RAC specific code goes here
$end
end;
/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment