oracle 向远程数据库服务器插入数据
首先要建立远程数据库
1、在oracle数据库中建立链接串
如果是windows系统,直接使用Net configuration Asistant创建链接
如果是linux系统,用telnet登录后,使用root帐号登录到系统
使用su – oracle 转换身份
然后找到oracle目录下的tnsnames.ora文件,将字符串写入
连接名=
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 服务器IP)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME =sid)
)
)
2、创建dblink
create public database link dblink名
connect to用户名
using'连接名';
使用dblink
select * from
表
关于同志近三年现实表现材料材料类招标技术评分表图表与交易pdf视力表打印pdf用图表说话 pdf
名@dblink名
3、创建存储过程
CREATE OR REPLACE PROCEDURE p_inserttoorcl
AS
tMaxDate Date;
BEGIN
tMaxDate :=sysdate;
--将时间减掉十秒,取出十秒前放弃的电话找出来,录入到业务表
insert into
CallFailInfo@ORCL(callid,devicetype,callerno,calleeno,waitbegin,w aitend,callbegin,callend)
select
t.callid,t.devicetype,t.callerno,t.calleeno,t.waitbegin,t.waitend ,t.callbegin,t.callend
from tbilllogbak t
where
--取出所有被放弃的电话
((t.devicetype=3 and t.callidnum=-1 and t.deviceno<>'2') --ivr放弃电话
or ( callidnum=-1 and devicetype=1) --队列放弃电话
or (callend=callbegin and devicetype=2 and callidnum=-1 and
calltype=0)--座席放弃或者未接通电话
)
--查找十秒前数据
and (tMaxDate-callbegin)*24*60*60>10 --and
(sysdate-callbegin)*24*60*60<610
-- 电话号码没有重新被打通
and t.callerno not in(select callerno from tbilllogbak b where
b.callbegin>t.callbegin and callend>callbegin and devicetype=2);
--提交数据
commit;
delete from tbilllogbak where (tMaxDate-callbegin)*24*60*60>10;
--and (sysdate-callbegin)*24*60*60<610
--提交数据
commit;
END p_inserttoorcl;
4、创建作业
begin
dbms_job.submit(:jobno, 'p_inserttoorcl;',
sysdate,'sysdate+1/24/6');--十分钟
commit;
end;
/
5、删除作业
如果作业不用了,就用以下的
方法
快递客服问题件处理详细方法山木方法pdf计算方法pdf华与华方法下载八字理论方法下载
删除作业,这样就不会继续运行存储过程
begin
dbms_job.remove(202);
commit;
end;
/
继续阅读