?
Solved

Data from one database not transferred to another database (using DB LINK) if user is not OBJECT OWNER

Posted on 2006-11-15
8
Medium Priority
?
747 Views
Last Modified: 2012-05-05
Hi.

I am using Oracle Forms in my application. Users for the application are setup to be either an 'OBJECT OWNER' or an 'APPLICATION USER'.

I have a screen that calls a package to transfer data from the current database to another database, using a PUBLIC DATABASE LINK.

Unfortunately when the user that processed the data transfer is NOT THE OBJECT OWNER (i.e. just an APPLICATION USER), I get the error: "ORA-02070: database  does not support  in this
context". I think it may be because my table has a default of SYS_CONTEXT('APP','BRANCH') in one of its fields. Unfortunately, I need this default for the forms processing.

I have also tried using the OBJECT OWNER to do the processing and it is working fine. Unfortunately, there may be cases when the user to do the processing is not the object owner, so I need to have this problem fixed.

Please help. This is kinda urgent.

Thanks.
0
Comment
Question by:m_denise
[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
  • 5
  • 3
8 Comments
 
LVL 48

Accepted Solution

by:
schwertner earned 1500 total points
ID: 17954154
Create PUBLIC SYNONYM  over this table.
0
 

Author Comment

by:m_denise
ID: 17954399
Kindly expound on how I will need to create a PUBLIC SYNONYM (do I need to create it for a specific field or to the whole table itself? do I need to create it to the SOURCE table or the DESTINATION table?).

Because I have not used that before in any of my applications yet.

Thanks.
0
 
LVL 48

Expert Comment

by:schwertner
ID: 17954901
Seems I misunderstood you.

So, you have a package that has a procedure that works fine
under the domain of the user 'OBJECT OWNER' ,
but fails if it runs under the domain of 'APPLICATION USER'.

I hope the owner of the procedure is 'OBJECT OWNER' ,

Try this:

as 'OBJECT OWNER' :
SQL>grant execute on procedure_name to 'APPLICATION USER';

The idea is that the procedure will be invoked by 'APPLICATION USER'
but will run under the domain of 'OBJECT OWNER' .
0
Industry Leaders: 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!

 

Author Comment

by:m_denise
ID: 17962068
Actually, the procedure itself works fine whether I run it with 'OBJECT OWNER' OR 'APPLICATION USER'.

In my procedure, I have this command to transfer data from the current database to another database using a DB Link:
          EXECUTE IMMEDIATE 'INSERT INTO DEST_TABLE@'|| v_dblink ||
                            ' SELECT * FROM SOURCE_TABLE WHERE TRAN_DATE = :x'
                          using v_syst_date;

This command is what does not work when the 'APPLICATION USER' is running the procedure.
0
 

Author Comment

by:m_denise
ID: 17963239
I have tried creating and using a SYNONYM for the SOURCE_TABLE as you said:
CREATE OR REPLACE PUBLIC SYNONYM SOURCE_TABLE_SYN FOR '||
                     v_user||'.DEST_TABLE@'||v_dblink

I used it in the same procedure thru:
          EXECUTE IMMEDIATE 'INSERT INTO SOURCE_TABLE_SYN SELECT * FROM SOURCE_TABLE WHERE TRAN_DATE = :x'
                          using v_syst_date;

I still get the error: "ORA-02070: database  does not support  in this context" with that command when the procedure is run in the application by the 'APPLICATION USER'.
0
 
LVL 48

Expert Comment

by:schwertner
ID: 17963424
Upgrade the DB at least to 9.2.0.5 -----> bug 3277927!
0
 

Author Comment

by:m_denise
ID: 17976719
This is the current version of my database
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
PL/SQL Release 10.2.0.1.0 - Production
CORE    10.2.0.1.0      Production
TNS for Solaris: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
0
 

Author Comment

by:m_denise
ID: 17977053
I have tried to use a FOR LOOP for this problem and it's working if I explicitly hard-code the DB LINK name.

However, I have to use a variable for the DB LINK name because I cannot predict what the name will be. When using a variable for the DB LINK, I can't make my explicit insert statement work.

So instead, I explicitly inserted into the SYNONYM using the FOR LOOP:
FOR i in table_rec (date) --this cursor already selects my needed records
LOOP
  INSERT INTO TABLE_SYNONYM
   VALUES (k.value1, k.value 2);

  COMMIT;
END LOOP;
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
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 how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Suggested Courses

743 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