我需望通过ORA 的DBLINK 实现数据的同步功能;1.远程ORA和本地ORA 都是10g;
2.在远程ORA中创建了一个试图;
3.在本地ORA中创建了一个DBLINK;连接到远程ORA; >>>> DBLINK_HYDATA.US.ORACLE.COM
4.在本地机器上我VBS脚本实现从远程数据库到本地的实时更新;主要语句为:insert into salary_new(year,month,姓名,工号,岗位工资,实发岗位工资,生育保险,绩效工资,岗位工资考勤扣款,缺勤天数,经济责任目标奖,加班,中夜补贴,回帖,
女工卫生津贴,其他计发,应付工资,养老保险,公积金,失业保险,医疗保险,年金,宿舍费,代扣物管费,代扣水电费,个人所得税,其他扣款,实发工资,所在部门)
select year,month,姓名,工号,岗位工资,实发岗位工资,生育保险,绩效工资,岗位工资考勤扣款,缺勤天数,经济责任目标奖,加班,中夜补贴,回帖,女工卫生津贴,
其他计发,应付工资,养老保险,公积金,失业保险,医疗保险,年金,宿舍费,代扣物管费,代扣水电费,个人所得税,其他扣款,实发工资,所在部门
from hyhr.view_qj_salary@dblink_hydata.us.oracle.com A
where A.year=TO_NUMBER(to_char(sysdate,'yyyy')) and A.month=TO_NUMBER(to_char(sysdate,'mm'))
and not exists( select * from salary_new B where A.工号=B.工号 and B.year=TO_NUMBER(to_char(sysdate,'yyyy')) and B.month=TO_NUMBER(to_char(sysdate,'mm')))
我在程序中检测出了有新记录,但执行这条语句都是失败???我在PL/SQL中执行时,有时候成功,有时候失败???不知道通过DBLINK 进行连接ORA时候要注意些什么问题???请指教指教~~~~~~~~~~~~
2.在远程ORA中创建了一个试图;
3.在本地ORA中创建了一个DBLINK;连接到远程ORA; >>>> DBLINK_HYDATA.US.ORACLE.COM
4.在本地机器上我VBS脚本实现从远程数据库到本地的实时更新;主要语句为:insert into salary_new(year,month,姓名,工号,岗位工资,实发岗位工资,生育保险,绩效工资,岗位工资考勤扣款,缺勤天数,经济责任目标奖,加班,中夜补贴,回帖,
女工卫生津贴,其他计发,应付工资,养老保险,公积金,失业保险,医疗保险,年金,宿舍费,代扣物管费,代扣水电费,个人所得税,其他扣款,实发工资,所在部门)
select year,month,姓名,工号,岗位工资,实发岗位工资,生育保险,绩效工资,岗位工资考勤扣款,缺勤天数,经济责任目标奖,加班,中夜补贴,回帖,女工卫生津贴,
其他计发,应付工资,养老保险,公积金,失业保险,医疗保险,年金,宿舍费,代扣物管费,代扣水电费,个人所得税,其他扣款,实发工资,所在部门
from hyhr.view_qj_salary@dblink_hydata.us.oracle.com A
where A.year=TO_NUMBER(to_char(sysdate,'yyyy')) and A.month=TO_NUMBER(to_char(sysdate,'mm'))
and not exists( select * from salary_new B where A.工号=B.工号 and B.year=TO_NUMBER(to_char(sysdate,'yyyy')) and B.month=TO_NUMBER(to_char(sysdate,'mm')))
我在程序中检测出了有新记录,但执行这条语句都是失败???我在PL/SQL中执行时,有时候成功,有时候失败???不知道通过DBLINK 进行连接ORA时候要注意些什么问题???请指教指教~~~~~~~~~~~~
解决方案 »
- 如何使ORACLE的TABLE显示不是ID,而是DESCRIPTION 就像MS-Access的LOOK-UP table 功能一样?
- SOS,FORM開發,請各位幫忙
- 安装了两个客户端,在C#程序中怎么选择某一个来连接数据库?
- 目前遭遇数据库性能无法提高写库速度,寻求解决方案?
- oracle菜鸟提问: exp imp 备份及导入的问题
- oracle中复制Table的问题
- 求pl/sql代码
- 我装的ORACLE进SQL*Plus时,不知道用户名和口令怎么办?
- 菜鸟问题,有关SYS用户授权问题!
- 请教下面的pl/sql块有什么错,我是从816教材上抄下来的,运行时总出现“SP2-0552: 未说明结合变量"J"”的这样的错误,难道不能打开动态cu
- oracle一个问题,新手提问
- 一条oracle 中的sql语句?
用双引号括起来试下
失败报的是什么错?
应该是前面的部分吧,后面是ORACLE区分吧
我在PL/SQL 中可以访问,
但经常提示:dynamic performance tables not accessiable
automatic statistics disables for this session
you can disable statistics in the preference menu or obtain select
priviliges on th V$session V$sesstate and v$statname tables
其他计发,应付工资,养老保险,公积金,失业保险,医疗保险,年金,宿舍费,代扣物管费,代扣水电费,个人所得税,其他扣款,实发工资,所在部门
from hyhr.view_qj_salary@dblink_hydata.us.oracle.com A
where A.year=TO_NUMBER(to_char(sysdate,'yyyy')) and A.month=TO_NUMBER(to_char(sysdate,'mm'))
and not exists( select * from salary_new B where A.工号=B.工号 and B.year=TO_NUMBER(to_char(sysdate,'yyyy')) and B.month=TO_NUMBER(to_char(sysdate,'mm'))) 提示有新记录:但insert 时候报失败????????难道 insert into 前还有什么需要设置的????
'
' Ver 2009.09 by QJCF Happypolo
'
' 1.
' 2. 连接远程oracle; 取远程oracle 中当年当月的dataset not in 本地中的 insert to 本地oracle;
' 3. 日志写入txt文件,以日期年月为文件名称;
' 4. 控制每天执行一次;
' 5. 前提:在本地建立一 DBLINK 连接远程oracle;
' ===================================================================================
Do While True
dim f,txtfile'----------------- 创建日志文件对象, 判定30天前的log 文件是否存在,存在则删除!----
Set f = CreateObject("Scripting.FileSystemObject")
set txtfile = f.opentextfile("D:\oraTOora\log\"&year(date)&month(date)&".txt",8,True) '-------- 连接本地 oracle, insert oracle conn_local = "Provider=MSDAORA.1;Persist Security Info=True;User ID=qjcf;Password=qjcf;Data Source=webdata"
set rs_local = createobject("adodb.recordset") '----- 检测是否存在需要插入的记录? sql_local=" select count(*) as recnum "
sql_local=sql_local+" from hyhr.view_qj_salary@dblink_hydata.us.oracle.com A "
sql_local=sql_local+" where A.year=TO_NUMBER(to_char(sysdate,'yyyy')) and A.month=TO_NUMBER(to_char(sysdate,'mm')) "
sql_local=sql_local+" and not exists( select * from salary_new B where A.工号=B.工号 and B.year=TO_NUMBER(to_char(sysdate,'yyyy')) and B.month=TO_NUMBER(to_char(sysdate,'mm')))" Err.clear
On Error Resume Next '出错不显示,执行下一条 rs_local.open sql_local,conn_local,1,1 if Err.Number=0 Then ' 数据库连接 ok!
recordnum=rs_local("recnum") if cint(recordnum) >0 then '-------- 存在新记录:
sql_insert="insert into salary_new(year,month,姓名,工号,岗位工资,实发岗位工资,生育保险,绩效工资,岗位工资考勤扣款,缺勤天数,经济责任目标奖,加班,中夜补贴,回帖,"
sql_insert=sql_insert+"女工卫生津贴,其他计发,应付工资,养老保险,公积金,失业保险,医疗保险,年金,宿舍费,代扣物管费,代扣水电费,个人所得税,其他扣款,实发工资,所在部门) "
sql_insert=sql_insert+" select "
sql_insert=sql_insert+"year,month,姓名,工号,岗位工资,实发岗位工资,生育保险,绩效工资,岗位工资考勤扣款,缺勤天数,经济责任目标奖,加班,中夜补贴,回帖,女工卫生津贴,"
sql_insert=sql_insert+"其他计发,应付工资,养老保险,公积金,失业保险,医疗保险,年金,宿舍费,代扣物管费,代扣水电费,个人所得税,其他扣款,实发工资,所在部门 "
sql_insert=sql_insert+" from hyhr.view_qj_salary@dblink_hydata.us.oracle.com A "
sql_insert=sql_insert+" where A.year=TO_NUMBER(to_char(sysdate,'yyyy')) and A.month=TO_NUMBER(to_char(sysdate,'mm')) "
sql_insert=sql_insert+" and not exists( select * from salary_new B where A.工号=B.工号 and B.year=TO_NUMBER(to_char(sysdate,'yyyy')) and B.month=TO_NUMBER(to_char(sysdate,'mm')))" Flag_insert_num=10
do while Flag_insert_num>0 '循环10次 Err.clear
On Error Resume Next '出错不显示,执行下一条 rs_insert.open sql_local,conn_local,1,1 '执行插入SQL If Err.Number=0 Then
txtfile.writeline(date&" "&time&" -------------- "&Flag_insert_num&"插入记录 "&recordnum&" 条 ! --------- ")
Flag_insert_num=0
else
txtfile.writeline(date&" "&time&" -------------- "&Flag_insert_num&"存在记录 "&recordnum&" 插入数据失败 ! --------- ")
end if Flag_insert_num=Flag_insert_num-1
rs_insert.close
Loop else
txtfile.writeline(date&" "&time&" ------- 无新记录数据插入 ! ! !------ ")
end if
else
txtfile.writeline(date&" "&time&" connect false -------------- 数据库连接失败 ! --------- ")
end if
'-------------------------------------------------------- set f=nothing
set txtfile=nothing
set rs_local=nothing
' 间隔 1小时 执行一次 ms
WScript.Sleep 3600000
Loop
2009-11-16 9:58:56 -------------- 9存在记录 71 插入数据失败 ! ---------
2009-11-16 9:58:56 -------------- 8存在记录 71 插入数据失败 ! ---------
2009-11-16 9:58:56 -------------- 7存在记录 71 插入数据失败 ! ---------
2009-11-16 9:58:56 -------------- 6存在记录 71 插入数据失败 ! ---------
2009-11-16 9:58:56 -------------- 5存在记录 71 插入数据失败 ! ---------
2009-11-16 9:58:56 -------------- 4存在记录 71 插入数据失败 ! ---------
2009-11-16 9:58:56 -------------- 3存在记录 71 插入数据失败 ! ---------
2009-11-16 9:58:56 -------------- 2存在记录 71 插入数据失败 ! ---------
2009-11-16 9:58:56 -------------- 1存在记录 71 插入数据失败 ! ---------