日期:2014-05-17  浏览次数:20995 次

oracle 10g透明网关问题
这两天在测透明网关同步数据的问题,本机是10g32位的,连的是64位SQL SERVER2012的库。按照资料一步步已经配通了,查询SELECT * FROM prov@dlk正常显示出结果。然后我换了1张表查,SELECT * FROM contact直接报错“ORA-00910:指定的长度对于数据类型而言过长”。现在是SELECT就出错,我都还没试INSERT呢。。下面的操作就有点奇异了:
1、于是我就只查我需要的那些列:SELECT "ContactId","new_contact_id","FullName","ParentCustomerId","JobTitle","Telephone1","MobilePhone","Fax","EMailAddress1","Department","new_mobilephone2","new_fax2","Description","GenderCode","new_qqnumber" FROM Contact@dlk;也报一样的错。

2、我在SQL SERVER上用了SELECT * INTO Contact22 FROM Contact,然后SELECT "ContactId","new_contact_id","FullName","ParentCustomerId","JobTitle","Telephone1","MobilePhone","Fax","EMailAddress1","Department","new_mobilephone2","new_fax2","Description","GenderCode","new_qqnumber" FROM Contact22@dlk也报“ORA-00910”。

3、我先DROP了Contact22,然后SELECT ContactId,new_contact_id,FullName,ParentCustomerId,JobTitle,Telephone1,MobilePhone,Fax,EMailAddress1,Department,new_mobilephone2,new_fax2,Description,GenderCode,new_qqnumber INTO Contact22 FROM Contact,这时SELECT "ContactId","new_contact_id","FullName","ParentCustomerId","JobTitle","Telephone1","MobilePhone","Fax","EMailAddress1","Department","new_mobilephone2","new_fax2","Description","GenderCode","new_qqnumber" FROM Contact22@dlk忽然就可以了。

4、我再DROP TABLE Contact22,再SELECT * INTO Contact22 FROM Contact,这时SELECT "ContactId","new_contact_id","FullName","ParentCustomerId","JobTitle","Telephone1","MobilePhone","Fax","EMailAddress1","Department","new_mobilephone2","new_fax2","Description","GenderCode","new_qqnumber" FROM Contact22@dlk也可以。

SQL SERVER上的表结构部分如下:(
ContactId           uniqueidentifier,
new_contact_id      nvarchar(100),
FullName            nvarchar(160),
ParentCustomerId    uniqueidentifier,
JobTitle            nvarchar(100),
Telephone1          nvarchar(50),
MobilePhone         nvarchar(50),
Fax                 nvarchar(50),
EMailAddress1       nvarchar(100),
Department          nvarchar(100),
new_mobilephone2    nvarchar(100),
new_fax2            nvarchar(100),
Description         nvarchar(max),
GenderCode          int,
new_qqnumber        nvarchar(100)
)

我原以为是nvarchar的max长度或者uniqueidentifier类型的问题,uniqueidentifier的值是这样格式“726C095E-8DC0-4EED-BE59-0006381B8E69”,但是这样测试又不像了,反而像是缓存。。
有没谁懂透明网关的帮忙解释下,并提供个解决办法?
------解决方案--------------------
LZ做测试在详细一点!应该了解到具体是到哪一个字段出错了!
确实有可能是nvarchar的max长度或者是什么类型的问题哦!
如果你能继续还原错误就好了,试试在SqlServer中在新建一张跟contact结构一样的表,用于重现错误。
然后一个字段一个字段的查询(如果查询所有的时候有提示具体是那一列就不用这么干了),看看是哪个字段的问题。
如果是Description nvarchar(max) 那么就找一个Description内容最短的记录做条件查询看看是否继续报错!然后在找最长的。
在不报错的时候最好将查询的结果放到Oracle中的表里面。看看Oracle给你转换成了什么类型!

---------------来源网络----------------
通过透明网关传送过来的字符类型列会被加大为3倍
譬如原来的字符列长度是 VARCHAR2(100)  
到了ORACLE中就会变为 VARCHAR2(300)
因此如果原来的字符串是2000 到了ORACLE中就变为了6000 超过了VARCHAR2类型的最大支持长度
原文地址:http://www.itpub.net/forum.php?mod=viewthread&