Oracle存储过程报错ORA-02069: global_names parameter must be set to TRUE for this operation
2017-03-16 15:27
706 查看
今天开发给发邮件过来说一个存储过程想通过dblink往目标库insert数据,但报错ORA-02069: global_names parameter must be set to TRUE for this operation,想让我根据错误提示在数据库上修改global_names参数修改为True。
先来看看官方文档是如何介绍这个参数的:GLOBAL_NAMES specifies whether a database link is required to have the same name as the database to which it connects.
If the value of GLOBAL_NAMES is false, then no check is performed. If you use or plan to use distributed processing, then Oracle recommends that you set this parameter to true to ensure the use of consistent naming conventions for databases and links in a networked environment.从下面的查询可以看出global_names参数可以在线进行修改的
创建一个dblink
只能想其他的办法来绕过这个错误,这里给开发提了两个建议:
1、把存储过程部署到目标端来避免远程insert中调用sequence
2、在源端存储过程中引入临时表,先把数据插入临时表,再从临时表插入到远端表。
在MOS上搜到了一个相关文档(ORA-02069 DURING REMOTE INSERT OF A LOCAL SEQUENCE (文档 ID 1047673.6))跟我们的问题描述一致。
官方文档:http://docs.oracle.com/cd/E11882_01/server.112/e40402/initparams098.htm#REFRN10065
先来看看官方文档是如何介绍这个参数的:GLOBAL_NAMES specifies whether a database link is required to have the same name as the database to which it connects.
If the value of GLOBAL_NAMES is false, then no check is performed. If you use or plan to use distributed processing, then Oracle recommends that you set this parameter to true to ensure the use of consistent naming conventions for databases and links in a networked environment.从下面的查询可以看出global_names参数可以在线进行修改的
zx@TEST>col name for a30 zx@TEST>select name,ISSES_MODIFIABLE,ISSYS_MODIFIABLE from v$parameter where name='global_names'; NAME ISSES_MODIFIABL ISSYS_MODIFIABLE ------------------------------ --------------- --------------------------- global_names TRUE IMMEDIATE看完了这个参数,再来看看开发的存储过程代码,其中insert语句中是用到了一个序列,所以导致了这个报错。先在测试数据库上创建了一个简单的存储过程来模拟现再这个问题
创建一个dblink
zx@TEST>create database link link_orcl connect to zx identified by "zx" using 'orcl'; Database link created. zx@TEST>select * from dual@link_orcl; DUM --- X先创建一个不带序列的远程insert的存储过程
zx@TEST>create or replace procedure pro_a as 2 begin 3 insert into t2@link_orcl (c1) values('a'); 4 commit; 5 end; 6 / Procedure created.执行这个存储过程,观察结果,数据可以正常插入
zx@TEST>select * from t2@link_orcl; no rows selected zx@TEST>exec pro_a; PL/SQL procedure successfully completed. zx@TEST>select c1 from t2@link_orcl; C1 --- a创建一个序列,并修改上面的存储过程
zx@TEST>create sequence seq_a; Sequence created. zx@TEST>create or replace procedure pro_a as 2 begin 3 insert into t2@link_orcl (c1,n1) values('a',seq_a.nextval); 4 commit; 5 end; 6 / Procedure created.执行修改后的存储过程,重现上面的错误ORA-02069
zx@TEST>exec pro_a; BEGIN pro_a; END; * ERROR at line 1: ORA-02069: global_names parameter must be set to TRUE for this operation ORA-06512: at "ZX.PRO_A", line 3 ORA-06512: at line 1先在session层面修改global_names参数,再次执行存储过程,又出现了新的错误:说两端的数据库名不一致。
zx@TEST>alter session set global_names = true; Session altered. zx@TEST>exec pro_a; BEGIN pro_a; END; * ERROR at line 1: ORA-02085: database link LINK_ORCL connects to ORCL ORA-06512: at "ZX.PRO_A", line 3 ORA-06512: at line 1 zx@TEST>!oerr ora 2085 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.那现在问题来了,实际生产中源端和目标端的数据库名肯定是不一致的,所以修改这个参数并不能解决这个问题。
只能想其他的办法来绕过这个错误,这里给开发提了两个建议:
1、把存储过程部署到目标端来避免远程insert中调用sequence
2、在源端存储过程中引入临时表,先把数据插入临时表,再从临时表插入到远端表。
在MOS上搜到了一个相关文档(ORA-02069 DURING REMOTE INSERT OF A LOCAL SEQUENCE (文档 ID 1047673.6))跟我们的问题描述一致。
官方文档:http://docs.oracle.com/cd/E11882_01/server.112/e40402/initparams098.htm#REFRN10065
相关文章推荐
- 关于:ORA-02069: global_names parameter must be set to TRUE for this operation
- ORA-02069: global_names parameter must be set to TRUE for this operation
- ORA-02069: global_names parameter must be set to TRUE for this operation
- 关于:ORA-02069: global_names parameter must be set to TRUE for this operation
- 利用数据库链做DML操作时报ORA-02069: global_names parameter must be set to TRUE for this operation
- 解决ORA-02069: global_names parameter must be set to TRUE for this operation 问题
- ORA-02069: global_names parameter must be set to TRUE for this operation
- 关于:ORA-02069: global_names parameter must be set to TRUE for this operation
- DateTimePicker 控件出现 "You must be in ShowCheckbox mode to set to this date" 的错误
- could not be set to a 'string' value. You must set this property to a non-null value of type
- Swift Language Version” (SWIFT_VERSION) build setting must be set to a supported value for targets w
- “Swift Language Version” (SWIFT_VERSION) build setting must be set to a supported value for target
- DateTimePicker 控件出现 "You must be in ShowCheckbox mode to set to this date" 的错误
- DateTimePicker 控件出现 "You must be in ShowCheckbox mode to set to this date" 的错误
- Name for parameter binding must not be null or empty! On JDKs < 8, you need to use @Param for named
- [Graphics] UIColor created with component values far outside the expected range, Set a breakpoint on UIColorBreakForOutOfRangeColorComponents to debug. This message will only be logged once.
- Error: ORA-16698: LOG_ARCHIVE_DEST_n parameter set for object to be added
- mysql:Collations Must Be for the Right Character Set
- IdentifierGenerationException: ids for this class must be manually assigned before calling save()
- MPI编译C++程序出现#error "SEEK_SET is #defined but must not be for the C++ binding of MPI" 的解决方法