简体   繁体   English

如何使用SQL2000链接服务器查询Oracle 11G表

[英]How to use a SQL2000 Linked Server to query an Oracle 11G table

Can someone help me construct the SQL that I need to query the Projects_dim table using the Linked Server "idwd"? 有人可以帮助我使用链接服务器“ idwd”构造查询Projects_dim表所需的SQL吗?

To test the connection, I ran a sample query using the linked server name. 为了测试连接,我使用链接服务器名称运行了一个示例查询。 To access the tables on the linked server, I used a four-part naming syntax: 要访问链接服务器上的表,我使用了一个四部分的命名语法:

linked_server_name.catalog_ name.schema_name.table_name. linked_server_name.catalog_name.schema_name.table_name。

replacing the values, you get: 替换值,您将得到:

idwd.idwd.wimr.PROJECTS_DIM

of should it be the following? 应该是以下哪个?

idwd..wimr.PROJECTS_DIM

The database name is "idw" but the grid below shows a blank value under "catalog", which is one source of my confusion, though I believe that the more likely approach is to construct the syntax assuming that the catalog part of the qualified table name should be blank as in the following first example. 数据库名称为“ idw”,但是下面的网格在“目录”下显示了一个空白值,这是我感到困惑的原因之一,尽管我认为,更可能的方法是在假定合格表的目录部分的情况下构造语法名称应为空白,如以下第一个示例所示。

    select * from idwd..wimr.PROJECTS_DIM

    Server: Msg 7314, Level 16, State 1, Line 1
    OLE DB provider 'idwd' does not contain table '"wimr"."PROJECTS_DIM"'.  The table either does not exist or the current user does not have permissions on that table.

select * from idwd.idwd.wimr.PROJECTS_DIM

Server: Msg 7312, Level 16, State 1, Line 1
Invalid use of schema and/or catalog for OLE DB provider 'MSDAORA'. A four-part name was supplied, but the provider does not expose the necessary interfaces to use a catalog and/or schema.

Can someone suggest what I need to do to query this table? 有人可以建议我要查询该表吗?

I am using the MS OLEDB Driver for Oracle. 我正在使用MS OLEDB Driver for Oracle。

I thought perhaps there is an issue with case-sensitivity, so I tried this: 我以为可能是大小写敏感的问题,所以我尝试了一下:

select * from IDWD..WIMR.PROJECTS_DIM


Server: Msg 7356, Level 16, State 1, Line 1
OLE DB provider 'MSDAORA' supplied inconsistent metadata for a column. Metadata information was changed at execution time.

and this: 和这个:

select * from IDWD.IDWD.WIMR.PROJECTS_DIM

Server: Msg 7312, Level 16, State 1, Line 1
Invalid use of schema and/or catalog for OLE DB provider 'MSDAORA'. A four-part name was supplied, but the provider does not expose the necessary interfaces to use a catalog and/or schema.

I tried to create a linked server using each of the two likely drivers: 我尝试使用两个可能的驱动程序中的每个来创建链接服务器:

  1. Microsoft OLEDB Provider for Oracle Microsoft针对Oracle的OLEDB提供商
  2. Oracle Provider for OLEDB OLEDB的Oracle提供程序

..without luck. ..没有运气。

Do you think it could be a driver issue? 您是否认为这可能是驱动程序问题?

替代文字

I just resolved this issue. 我刚刚解决了这个问题。 Oracle was probably upgraded recently if it did worked before. 如果以前可以使用,Oracle可能最近已升级。

To resolve I connected to Oracle and did a "descr TABLENAME;" 为了解决这个问题,我连接到Oracle,并做了一个“ descr TABLENAME;”。 and check whatever column was in problem. 并检查有问题的列。 In my case, I had a column type as NUMBER without any scale like in this preview. 就我而言,我的列类型为NUMBER,没有像此预览中那样的任何比例。

预习

I asked a DBA to force a scale for these 3 columns and problem is now solved! 我要求DBA强制对这3列进行缩放,现在问题已解决!

But I did find also there is a workaround this solution. 但我确实发现此解决方案也有解决方法。 You can also change the TSQL 您也可以更改TSQL

from

SELECT * FROM idwd..wimr.PROJECTS_DIM

to

SELECT * FROM OPENQUERY(idwd,'select * from wimr.PROJECTS_DIM')

And Microsoft Support report a problem if nullability is not set on a column. 如果没有在列上设置可空性,Microsoft支持部门将报告一个问题。

More info about my search on Google . 有关我在Google上搜索的更多信息。

Sounds like you may be on the right track thinking about this as an issue of case sensitivity. 听起来您可能正处于正确的轨道上,将其视为区分大小写的问题。 Quoting from the Microsoft support document How to set up and troubleshoot a linked server to an Oracle database in SQL Server regarding errors 7312, 7313, 7314: 引用Microsoft支持文档中有关错误7312、7313、7314 的链接服务器到SQL Server中的Oracle数据库的设置和故障排除

If you receive these error messages, a table may be missing in the Oracle schema or you may not have permissions on that table. 如果收到这些错误消息,则Oracle架构中可能缺少表,或者您对该表没有权限。 Verify that the schema name has been typed by using uppercase. 验证是否使用大写形式输入了架构名称。 The alphabetical case of the table and of the columns should be as specified in the Oracle system tables. 表和列的字母大小写应与Oracle系统表中指定的相同。

On the Oracle side, a table or a column that is created without double quotation marks is stored in uppercase. 在Oracle方面,不带双引号创建的表或列以大写形式存储。 If the table or the column is enclosed in double quotation marks, the table or the column is stored as is. 如果表或列用双引号引起来,则表或列按原样存储。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM