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
745 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 500 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
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!

 

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

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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Oracle dataguard 5 60
Creation date for a PDB 5 63
Oracle DB Slows After Datapump Until Next Reboot 27 131
Oracle Distributed Transaction Lock Error ORA-01591 8 69
Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
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…
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
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

749 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