open v_curdblink;
loop
fetch v_curdblink into v_dbip, v_sid, v_dbuser, v_password, v_port;
exit when v_curdblink%notfound;
select upper('MMSEXP_')||replace(v_dbip,'.','X') into v_dblinkip from dual;
select count(1) into v_dblinknum from dba_db_links where db_link = v_dblinkip;
select count(1) into v_dblink from dba_db_links;
if v_dblinknum=0 or v_dblink=0 then
--创建DBLink Mmsexp_ip
v_todo := '创建DBLink';
v_sql := ' create database link MMSEXP_'||replace(v_dbip,'.','x')||
' connect to expdb identified by expdb ' ||
' using ''(description =' ||
' (address = (protocol = tcp)(host = ' || v_dbip ||
' )(port = ' || v_port || '))' || '(connect_data =' ||
' (server = dedicated)' || '(service_name = '||v_sid||')' || ')' ||
' )''';
execute immediate v_sql;
end if;
end loop;
close v_curdblink;