Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Querying remote database via database link

Posted on 2013-06-03
6
Medium Priority
?
467 Views
Last Modified: 2013-06-04
I need to get data from RemoteDB1 while I am logged in to SourceDB. I found that there are two database links previously created on SourceDB to RemoteDB1, called SourceDB_TO_RemoteDB and RemoteDB.

When I queried dba_db_links, I saw that OWNER for both links is PUBLIC, and username for both links is RemoteDB (same as the GLOBAL_NAME in the RemoteDB).

RemoteDB user does not exist in RemoteDB1 but not in SourceDB.

Now I also have user RPT in RemoteDB1 database that has a view in its schema Main_view. Main_view was created on a couple of catalog views that user RPT has SELECT privileges on.

SourceDB also has a user RPT created.

I was trying to use datbase link RemoteDB while logged in to the SourceDB to access Main_view in RPT user schema:

SELECT FIELD1 "Field 1", FIELD2 "Field 2"
FROM Main_view@RemoteDB
WHERE START_TIME > SYSDATE-1
AND FIELD3='Open'
ORDER BY FIELD1;

I get an error

ERROR at line 2:
ORA-00942: table or view does not exist
ORA-02063: preceding line from RemoteDB

I have gotten this error both, while logged in as RPT user and as SYS user.

Can someone help me to query data from RemoteDB1?
0
Comment
Question by:YZlat
  • 3
  • 2
6 Comments
 
LVL 35

Assisted Solution

by:johnsone
johnsone earned 1000 total points
ID: 39217290
The error would indicate that the either the user that is connecting to the remote db doesn't have privileges, or you are using an incorrect name.

What happens if you try:

SELECT FIELD1 "Field 1", FIELD2 "Field 2"
FROM RPT.Main_view@RemoteDB
WHERE START_TIME > SYSDATE-1
AND FIELD3='Open'
ORDER BY FIELD1;
0
 
LVL 35

Author Comment

by:YZlat
ID: 39217307
I tried that and gotten the same error.

I was wondering how would I give the user on SourceDB priveleges on a view on RemotDB1?
0
 
LVL 35

Expert Comment

by:johnsone
ID: 39217333
The user on SourceDB doesn't need privileges on RemotDB1.  The user that the database link connects as in RemotDB1 needs the privilege.  My guess is that you need to connect to RemotDB1 and grant privileges on the view you are trying to select from (RPT.MAIN_VIEW) to the user the link is connecting as.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 7

Accepted Solution

by:
Docteur_Z earned 1000 total points
ID: 39218480
Yous wrote
RemoteDB user does not exist in RemoteDB1 but not in SourceDB.
I guess you've ment "RemoteDB user does exist in RemoteDB1 but not in SourceDB."

So your issue is that this RemoteDB  user doesn't have the necessary grants on the view you want to query (RPT.MAIN_VIEW). So all the tables underlying this view.
0
 
LVL 35

Author Comment

by:YZlat
ID: 39218808
Docteur_Z, yes that's the issue. I did grant the RemoteDB user on the Main_view but still no difference.

What I found is that the underlying view for Main_view is a nother view that is in RemoteDB user's schema. Shouldn't RemoteDB user have privileges then?
0
 
LVL 35

Author Comment

by:YZlat
ID: 39218820
Got it!

I needed to do two things:

1) Grant SELECT permissions on Main_view to RemoteDB user
2) Perfix Main_view name with schema name when querying from SourceDB

Thanks guys!
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question