1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| CREATE OR REPLACE PROCEDURE Script_chargement_ODS_1Bis IS
CURSOR c_table IS
SELECT vsource.view_name, tcible.table_name
FROM SYS.ALL_TABLES tcible, SYS.ALL_VIEWS vsource
WHERE tcible.OWNER = 'IHR' and vsource.OWNER = 'IHR'
and tcible.table_name like 'HRA_%' and tcible.table_name not like 'HRA_ZX%'
and tcible.table_name not like 'HRA_ZY%' and vsource.view_name like 'ODS_%'
and vsource.view_name not like 'ODS_ZX%' and vsource.view_name not like 'ODS_ZY%'
and rtrim(substr(tcible.table_name,4,25)) = rtrim(substr(vsource.view_name,4,25))
and tcible.table_name not in (SELECT substr ( tcible.table_name , 1 , INSTR(tcible.table_name,'TMP',1) - 2 )
FROM SYS.ALL_TABLES tcible
WHERE tcible.table_name like 'HRA_%'
AND tcible.table_name like '%TMP') ;
i c_table%ROWTYPE;
BEGIN
dbms_output.enable(9999999);
dbms_output.put_line ('Test avec dbms_output');
FOR i IN c_table LOOP
dbms_output.put_line (i.table_name);
dbms_output.put_line (i.view_name);
dbms_output.put_line ('truncate table IHR.' || i.table_name);
dbms_output.put_line ('Insert into IHR.' || i.table_name || ' select * from IHR.' || i.view_name);
EXECUTE IMMEDIATE 'truncate table IHR.' || i.table_name ;
EXECUTE IMMEDIATE 'Insert into IHR.' || i.table_name || ' select * from IHR.' || i.view_name ;
commit;
END LOOP;
END; |
Partager