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

和自甴很熟 提交于 2019-12-22 17:06:25

问题


Can someone help me construct the SQL that I need to query the Projects_dim table using the Linked Server "idwd"?

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.

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.

    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.

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
  2. Oracle Provider for OLEDB

..without luck.

Do you think it could be a driver issue?


回答1:


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:

If you receive these error messages, a table may be missing in the Oracle schema or you may not have permissions on that table. 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.

On the Oracle side, a table or a column that is created without double quotation marks is stored in uppercase. If the table or the column is enclosed in double quotation marks, the table or the column is stored as is.




回答2:


I just resolved this issue. Oracle was probably upgraded recently if it did worked before.

To resolve I connected to Oracle and did a "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.

I asked a DBA to force a scale for these 3 columns and problem is now solved!

But I did find also there is a workaround this solution. You can also change the 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.

More info about my search on Google.



来源:https://stackoverflow.com/questions/3534453/how-to-use-a-sql2000-linked-server-to-query-an-oracle-11g-table

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!