日期:2014-05-17 浏览次数:21005 次
create or replace procedure procedure_test
Authid Current_User
is
crcode varchar2(8);
crname varchar2(60);
ressql varchar2(100);
begin
execute immediate 'create database link REMOTE_DEV_HOST
connect to remote_dev identified by remote_dev
using '' (DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.0.13.24)(PORT = 1521))
)
(CONNECT_DATA =
(SID = remote_dev)
(SERVER = DEDICATED)
)
)''';
declare cursor cur1 is
select rcode, rname from table_sour@remote_dev_host;
begin
open cur1;
loop
fetch cur1 into crcode, crname;
exit when cur1%notfound;
select count(*) into ressql from table_des where rcode = crcode;
if(ressql <> '0') then
update table_des set rname = crname where rcode = crcode;
commit;
end if;
end loop;
close cur1;
end cur1;
execute immediate 'alter session close database link REMOTE_DEV_HOST';
execute immediate 'drop database link REMOTE_DEV_HOST';
end;