Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Querying remote database via database link

Posted on 2013-06-03
6
Medium Priority
?
458 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
Suggested Courses

661 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