SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Linked Server Oracle Unable to execute select QUERY


Linked Server Oracle Unable to execute select QUERY

Author
Message
funooni
funooni
Old Hand
Old Hand (321 reputation)Old Hand (321 reputation)Old Hand (321 reputation)Old Hand (321 reputation)Old Hand (321 reputation)Old Hand (321 reputation)Old Hand (321 reputation)Old Hand (321 reputation)

Group: General Forum Members
Points: 321 Visits: 294
Gentlemen

I have browsed lots of threads after which i achieved my initial target, however, this is something i could not find out.

I have the following Setup:

1) SQL SERVER 2005 Developer Edition Running on Windows XP
2) Oracle Developer Toolkit and ODAC (ODTwithODAC112012.zip)
3) Linked Server Oracle is accessible with following details

EXEC master.dbo.sp_addlinkedserver @server = N'ORCNOTNS',
@srvproduct=N'OracleDSN',
@provider=N'OraOLEDB.Oracle',
@datasrc=N'ORCLDSN',
@provstr=N'Provider=OraOLEDB.Oracle;Data Source=(DESCRIPTION=(CID=GTU_APP)(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=SERVER)(PORT=1522)))(CONNECT_DATA=(SID=ORACLE)(SERVER=DEDICATED)));User Id=USER;Password=PASSWORD;'

Allow Inprocess is unchecked.
Collation Compatible True
Data Access True
RPC True
RPC Out True
Use Remote Collation True
Collation Name <<BLANK>>
Provider used is OraOLEDB.Oracle


The connection is successfull as i checked it from right click server and then test connection

Moreover, following query works successfully:

insert into ORCNOTNS..SCHEMA.Table values ( 11,21,'abc','varchar',51,getdate(),'varchar','varchar','varchar',101,'C',getdate())



The values are inserted into the respective table in Oracle and i can query them from Oracle SQLPlus client. However, the getdate() datetime is truncated to date only.

My problem is that when i execute the following query it gives me an error:

SELECT * FROM ORCNOTNS..SCHEMA.Table



Msg 7320, Level 16, State 2, Line 1
Cannot execute the query "SELECT "Tbl1002"."COLUMN_A" "Col1004" FROM "SCHEMA"."TABLE" "Tbl1002"" against OLE DB provider "OraOLEDB.Oracle" for linked server "ORCNOTNS".



However, this query does bring the column headers for this table.

Whereas when i execute the OPENQUERY using the following :

select * from openquery(ORCNOTNS,'SELECT * FROM SCHEME.TABLE')



This shows me the following error:

Msg 7320, Level 16, State 2, Line 1
Cannot execute the query "SELECT * FROM SCHEMA.TABLE" against OLE DB provider "OraOLEDB.Oracle" for linked server "ORCNOTNS".



I have full control over my SQL Server 2005 i can make changes amendments etc. However, Oracle server is at client site and i don't have any privileges except Insert , Delete and select statements.

What bothers me more is that i can insert but i cannot select.

Please let me know if any other info is required.

Your help is highly appreciated.

Zee
Geoff A
Geoff A
Ten Centuries
Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)

Group: General Forum Members
Points: 1386 Visits: 1803
does this work?

select * from openquery([ORCNOTNS],'select * from all_objects')
funooni
funooni
Old Hand
Old Hand (321 reputation)Old Hand (321 reputation)Old Hand (321 reputation)Old Hand (321 reputation)Old Hand (321 reputation)Old Hand (321 reputation)Old Hand (321 reputation)Old Hand (321 reputation)

Group: General Forum Members
Points: 321 Visits: 294
No it gives the same error message

however i was just trying some commands and i found that the following works and returns all the tables.

exec sp_tables_ex @table_server = 'ORCNOTNS'


I dont understand what is wrong with select query.
Geoff A
Geoff A
Ten Centuries
Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)

Group: General Forum Members
Points: 1386 Visits: 1803
it may be related to the user defined in your linked server not having permissions.
Emanuele Andreoli
Emanuele Andreoli
Forum Newbie
Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)

Group: General Forum Members
Points: 9 Visits: 26
Hi,
i just got into a similar problem.
Created a linked server on my Sql Server 2008 R2, this for an instance of Oracle11.2g

After lots of troubles, finllay got to create the bloody linked server and when trying to select some data from it, sql always prompted an error like "cannot find table bla bla".

Got the trick, you have to make:

"Select * from [linkedserver]..[schemaname].[tableName]"

hope it helps! Smile
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search