WHENEVER SQLERROR EXIT FAILURE
SET SERVEROUTPUT ON
SET TIMING ON
SET ECHO ON
SET HEADING OFF
SET FEEDBACK ON
SET VERIFY OFF

var filename VARCHAR2(100)
BEGIN
	SELECT 'INSTALL_MARS_783_' || SUBSTR(PDB_NAME, (INSTR(PDB_NAME,'_',1)+1), (LENGTH(PDB_NAME)-INSTR(PDB_NAME,'_',1))) ||  '_' ||TO_CHAR(SYSDATE,'YYYYMMDD_HH24MISS')||'.log' INTO :filename from DBA_PDBS;
END;
/
column filename new_value _filename
select :filename filename from dual;
spool &_filename 

prompt ##### started at time #####
select systimestamp from dual;
prompt ##### database name #####
SELECT  SUBSTR(PDB_NAME, (INSTR(PDB_NAME,'_',1)+1), (LENGTH(PDB_NAME)-INSTR(PDB_NAME,'_',1))) AS PDB_NAME FROM DBA_PDBS;


@@01_MARS_783_install_BKP_MRDS
@@00_MARS_783_backup_CT_MRDS_A_WORKFLOW_HISTORY.sql
@@00_MARS_783_backup_CT_MRDS_A_TASK_HISTORY.sql
@@00_MARS_783_backup_CT_MRDS_A_TASK_HISTORY_SOURCE.sql
@@00_MARS_783_backup_CT_MRDS_A_TASK_HISTORY_TARGET.sql
@@01_MARS_783_install_CT_MRDS_A_WORKFLOW_HISTORY.sql
@@01_MARS_783_install_CT_MRDS_A_TASK_HISTORY.sql
@@01_MARS_783_install_CT_MRDS_A_TASK_HISTORY_SOURCE.sql
@@01_MARS_783_install_CT_MRDS_A_TASK_HISTORY_TARGET.sql


SET ECHO OFF

prompt ##### completed at time #####
select systimestamp from dual;

SPOOL OFF
EXIT