[错误处理]ORA-02069: global_names parameter must be set to TRUE for this operation
通过dblink update远程表时遇到下面的问题
UPDATE USER_ALL@LINK_001_USER B
SET SET_TIME=(SELECT MIN(LOG_TIME) FROM XX.XXX A
WHERE A.PID=B.PRODUCT_ID AND A.MD5ID=B.MD5ID AND LOG_TIME=getday(sysdate-2)
GROUP BY PID,MD5ID)
WHERE EXISTS (SELECT 1 FROM XX.XXXX A
WHERE A.PID=B.PRODUCT_ID AND A.MD5ID=B.MD5ID AND LOG_TIME=GETDAY(SYSDATE-2)
GROUP BY PID,MD5ID) AND VALID_TIME IS NULL
SQL 错误: ORA-02069: global_names parameter must be set to TRUE for this operation
02069. 00000 - "global_names parameter must be set to TRUE for this operation"
*Cause: A remote mapping of the statement is required but cannot be achieved
because global_names should be set to TRUE for it to be achieved
*Action: Issue alter session set global_names = true if possible
办法1:
根据提示把global_names设置为true;
alter session set global_names = true;
UPDATE USER_ALL@LINK_001_USER B
SET SET_TIME=(SELECT MIN(LOG_TIME) FROM XX.XXX A
WHERE A.PID=B.PRODUCT_ID AND A.MD5ID=B.MD5ID AND LOG_TIME=getday(sysdate-2)
GROUP BY PID,MD5ID)
WHERE EXISTS (SELECT 1 FROM XX.XXXX A
WHERE A.PID=B.PRODUCT_ID AND A.MD5ID=B.MD5ID AND LOG_TIME=GETDAY(SYSDATE-2)
GROUP BY PID,MD5ID) AND VALID_TIME IS NULL
错误报告:
SQL 错误: ORA-02085: 数据库链接LINK_001_USER 连接到 xxx
02085. 00000 - "database link %s connects to %s"
*Cause: a database link connected to a database with a different name.
The connection is rejected.
*Action: create a database link with the same name as the database it
connects to, or set global_names=false.
依然报错,上面的提示意思是:dblink的名字和连接到的数据库的名字应该一致。
**********
如果允许,可以考虑修改dblink的名字和连接到的数据库名字一致(名字通过select * from global_name获得),这样就解决问题了。
**********
我这里dblink的名字和连接到的数据库名字不同,且无法修改dblink的名字,所以这个办法无法解决问题。
办法2:
上面的sql中,有一个本地函数getday,但是在远程数据库中并不存在getday函数,所以会产生这个错误。
解决办法:在远程数据库上创建getday函数。
参考:
Inserting Data To View Mapped Via Dblink To Remote Table Returns Ora-02069 [ID 467787.1]
Ora-02069 When Using a Local Function While Updating a Remote Table [ID 342320.1]
阅读(10550) | 评论(0) | 转发(0) |