Below is a simple PL/SQL script that can be used to change parameter if needed. If the parameter is already set, nothing happens.
In my case, it was the parameter "recyclebin" that was needed to be switched from OFF to ON for some databases, but it could be any parameter.
Surely there are many ways to solve such a problem, this was how I solved it with very little effort :-)
set serveroutput on
set feedback off
set echo off
set verify off
DECLARE
v_db_name v$database.name%%TYPE;
v_rb v$system_parameter.name%%TYPE;
BEGIN
execute immediate 'alter session set nls_language=''american''';
select name
into v_db_name
from v$database;
select value
into v_rb
from v$system_parameter
where name = 'recyclebin';
--dbms_output.put_line('v_db_name: ' || v_db_name);
--dbms_output.put_line('v_rb: ' || v_rb);
CASE
WHEN v_rb = 'ON' THEN
dbms_output.put_line('Database ' || v_db_name || ': recyclebin already enabled.');
ELSE
dbms_output.put_line('Database ' || v_db_name || ': recyclebin is currently disabled. Turning it on now...');
execute immediate 'alter system set recyclebin=ON scope=spfile';
dbms_output.put_line('Database ' || v_db_name || ' now has recyclebin=ON in spfile. Database must be bounced in in order to enable the setting');
END CASE;
END;
/
exit
When we execute the script through emcli, the syntax comes to:
emcli execute_sql -sql="FILE" -iemcli execute_sql -sql="FILE" -input_file="FILE:/scripts/chk_and_alter_param.sql" -targets="TEST_DBS:composite"
No comments:
Post a Comment