SET TERMOUT ON
SET ECHO OFF
SET VERIFY OFF


SPOOL rm_install.log

ACCEPT Server PROMPT 'Enter DATABASE name (default - MAGICASH): ' DEFAULT MAGICASH
ACCEPT SYSpsw PROMPT 'Enter SYS password: ' DEFAULT NCTSYS HIDE

CONNECT SYS/&SYSpsw@&Server AS SYSDBA

ACCEPT fpath PROMPT 'Enter PATH to FRA (default - C:\oracle\product\10.2.0\flash_recovery_area): ' DEFAULT C:\oracle\product\10.2.0\flash_recovery_area

SET HEADING OFF
SELECT 			'Recommended MAX size of FRA - ' || 
				CASE 
				WHEN ROUND( ( SELECT COUNT (1) FROM V_$LOG_HISTORY WHERE FIRST_TIME >= (SYSDATE - 8) )  * 
				( select ROUND(SUM(t2.bytes)/1024/1024/1024,0) from v$log t2 ), 0) < (select round(sum(t.bytes)/1024/1024/1024,0) from v$datafile t) 
				THEN (select round(sum(t.bytes)/1024/1024/1024,0) from v$datafile t) 
				ELSE ROUND( ( SELECT COUNT (1) FROM V_$LOG_HISTORY WHERE FIRST_TIME >= (SYSDATE - 8) )  * 
				( select ROUND(SUM(t2.bytes)/1024/1024/1024,0) from v$log t2 ), 0) 
				END || 
				'G' 
FROM DUAL;
SET HEADING ON

ACCEPT fsize PROMPT 'Enter MAX size of FRA (default - 100G (G for Gigabytes)): ' DEFAULT 100G

SET HEADING OFF
SELECT DECODE(value, NULL, 'ERROR!!! - PFILE', 'SPFILE - OK.')
FROM sys.v_$parameter WHERE name = 'spfile';
SET HEADING ON


alter system set control_file_record_keep_time=45;
alter system set db_recovery_file_dest_size=&fsize;
alter system set db_recovery_file_dest='&fpath'; 

shutdown immediate
startup mount

alter database archivelog;
alter database open;
archive log start;

alter system switch logfile;
alter system switch logfile;
alter system switch logfile;
alter system switch logfile;

SPOOL OFF

SET FEEDBACK ON
SET TERMOUT ON
SET ECHO ON
EXIT
