Tuesday, February 5, 2008

PL/SQL to generate a DBMS_TTS.TRANSPORT_SET_CHECK to verify wether the tablespace set is self-contained

SET SERVEROUTPUT ON
/* PL/SQL to generate a DBMS_TTS.TRANSPORT_SET_CHECK to verify wether the tablespace set is self-contained before the transportation process */
DECLARE
/* You must customize this cursor: it represents the list of TS to transport */
CURSOR C IS select tablespace_name from dba_tablespaces where tablespace_name not in ('SYSTEM','SYSAUX','UNDOTBS','XDB','TOOLS','OWB_DATA','OWB_INDX','ODM','DRSYS','EXAMPLE','FD','FD_TEMP','CWMLITE','INDX','STATPACK') AND CONTENTS='PERMANENT' order by 1;
FC C%ROWTYPE;
i number;
BEGIN
dbms_output.put_line('-------------- C U T - H E R E --------------------------');
dbms_output.put_line('BEGIN /* DBMS_TTS.TRANSPORT_SET_CHECK EN PRO */');
dbms_output.put_line('SYS.DBMS_TTS.TRANSPORT_SET_CHECK (');
open c;
fetch c into fc;
i:=0;
dbms_output.put('''');
loop
dbms_output.put(fc.tablespace_name||',');
if i<3 then i:=i+1;
else dbms_output.put_line(''''); dbms_output.put('||''');
i:=0;
end if;
fetch c into fc;
exit when c%notfound;
end loop;
close c;
dbms_output.put_line(','');');
dbms_output.put_line('END; ');
dbms_output.put_line('/');
dbms_output.put_line(chr(10));
dbms_output.put_line('-------------- C U T - H E R E -------------------------');
dbms_output.put_line('SELECT * FROM TRANSPORT_SET_VIOLATIONS;');
END;
/

Example output:

-------------- C U T H E R E --------------------------
BEGIN /* DBMS_TTS.TRANSPORT_SET_CHECK EN PRO */
SYS.DBMS_TTS.TRANSPORT_SET_CHECK (
'USERS,,');
END;
/


-------------- C U T H E R E -------------------------
SELECT * FROM TRANSPORT_SET_VIOLATIONS;

Procedimiento PL/SQL terminado correctamente.

No comments: