Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

环境

oracle 版本 11.2r sqlserver 2012

需求

Oracle 通过 gateway dblink 打通和 sqlserver的连接。用户能够直接访问oracle获得sqlserver的数据。

关键问题

select * from dbo.Alarm@LINK_ASDWMS
> ORA-01002: fetch out of sequence
ORA-02063: preceding line from LINK_ASDWMS

> 时间: 0.353s

当所有配置完成后,查询sqlserver下的表时,会报这个错误。

猜测

  1. 猜测一

通过配置,oracle应该是可以检测到sqlserver的存在

我为什么会得出这个结论,原因如下:

当我修改 select 语句,查询一个完全不存在的表时

select * from dbo.NotFount@LINK_ASDWMS
> ORA-00942: table or view does not exist
[Oracle][ODBC SQL Server Driver][SQL Server]对象名 'DBO.NOTFOUNT' 无效。 {42S02,NativeErr = 208}[Oracle][ODBC SQL Server Driver][SQL Server]无法预定义语句。 {42000,NativeErr = 8180}
ORA-02063: preceding 2 lines from LINK_ASDWMS

> 时间: 0.1s

能够精准的报错,提示表不存在。

  1. 猜测二

数据可能没有正常返回到oracle就报错了,因为查了两张表,一张有 163373 万条数据,另一个是0条数据,执行速度都差不多,在有些情况下,0条数据的表执行速度甚至还更慢。

配置

# C:product11.2.0g_1dg4msqladmininitdg4msql.ora
HS_FDS_CONNECT_INFO=[172.16.xxx.xx1,1433]/instanceName/dbName
HS_FDS_TRACE_LEVEL=OFF
HS_FDS_RECOVERY_ACCOUNT=sa
HS_FDS_RECOVERY_PWD=xxxxxxxxx
# C:product11.2.0g_1NETWORKADMINlistener.ora
SID_LIST_LISTENER=
  (SID_LIST=
    (SID_DESC=
      (SID_NAME= dg4msql)
      (ORACLE_HOME = C:product11.2.0g_1)
      (PROGRAM= dg4msql)
    )
  )
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = WIN-V11L22M0BL3)(PORT = 15210))
    )
  )
ADR_BASE_LISTENER = C:product11.2.0g_1

Dblink 创建语句

create public database link LINK_ASDWMS connect to "sa" identified by "xxxxxxxx" using '(DESCRIPTION =
  (ADDRESS =
    (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 15210)
  )
  (CONNECT_DATA =
    (SERVICE_NAME = ASD_WMS)
  )
  (HS = OK)
)';

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
340 views
Welcome To Ask or Share your Answers For Others

1 Answer

等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...