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 force type schema_local.distant_typ AS object (
champ1 number(10,0),
champ2 varchar2(20),
champ3 number(10,0),
champ4 number(10,0));
/
CREATE or replace force type schema_local.distant_typ_tab AS TABLE of distant_typ;
/
DECLARE
CURSOR get_data_from_db IS
SELECT champ1, champ2, champ3, champ4
FROM schema_distant.ma_table_distante@mon_dblink
WHERE EXISTS(select 1 from schema_local.autre_table_locale where ma_table_distante.champ4=autre_table_locale.champ4);
BEGIN
OPEN get_data_from_db;
LOOP
FETCH get_data_from_db BULK collect INTO schema_local.distant_typ_tab LIMIT 1000;
FOR i in 1..distant_typ_tab.COUNT
LOOP
INSERT /* append */ INTO schema_local.table_locale
(champ1, champ2, champ3, champ4)
SELECT champ 1, champ2, champ3, champ4
FROM table (distant_typ_tab);
EXIT WHEN get_data_from_db%notfound;
END LOOP;
END LOOP;
COMMIT;
END;
/ |
Partager