If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Oracle > How to access the tables from others user?

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-02-09, 11:30
jp7234 jp7234 is offline
Registered User
 
Join Date: Aug 2006
Posts: 58
How to access the tables from others user?

Hello , everyone.

Here I have written a Package in Oracle 10g as follow:
①HEAD:
CREAT OR REPLACE PACKAGE cm.com
IS
PROCEDURE IsOK(name OUT VARCHAR2);
END cm.com;

①BODY:
CREAT OR REPLACE PACKAGE BODY cm.com
IS
PROCEDURE IsOK(name OUT VARCHAR2)
IS
w_person_name VARCHAR2(50);
w_sys_name VARCHAR2(50);

BEGIN
 SELECT person_name INTO w_person_name from person_t;
 SELECT sys_name INTO w_sys_name from system_t;
 name := w_person_name||w_sys_name;
END IsOK;

END cm.com;

Here:
①person_t is belonged to the user [cm]
②system_t  is belonged to the user [dm]. However the user [cm] have the only previlage [select] to the dm.system_t.

The problem is:
When I compiled the package, there was a error : the table or view system_t not exist.... But, in PL/SQL DEVELOPER, I logged in with the user cm, I could get the data form system_t with the statement:
①select * from system_t.

I can use the following way to get data in the package:
①SELECT sys_name INTO w_sys_name from dm.system_t;
BUt I do not want to use the shema in front of the table [system_t] or synonyms. Are there other ways for this?

Thank very much!

Reply With Quote
  #2 (permalink)  
Old 07-02-09, 11:50
anacedent anacedent is offline
Registered User
 
Join Date: Aug 2003
Location: Where the Surf Meets the Turf @Del Mar, CA
Posts: 4,931
>BUt I do not want to use the shema in front of the table [system_t] or synonyms.
>Are there other ways for this?
No other way
__________________
You can lead some folks to knowledge, but you can not make them think.
The average person thinks he's above average!
Reply With Quote
  #3 (permalink)  
Old 07-02-09, 13:28
shammat shammat is offline
Registered User
 
Join Date: Nov 2003
Posts: 1,517
Quote:
Originally Posted by jp7234
BUt I do not want to use the shema in front of the table [system_t] or synonyms. Are there other ways for this?
Why don't you want to use synonyms? A user synonym is the perfect solution for your problem. You can even automate the creation for that.

The only other workaround would be to use views but that is more or less the same as user synonyms.

On a side note: tables in Oracle are never written with this strange bracket notation
Reply With Quote
  #4 (permalink)  
Old 07-03-09, 02:03
jp7234 jp7234 is offline
Registered User
 
Join Date: Aug 2006
Posts: 58
Thank you very much. So, i have to use synonyms.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On