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
741 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
  • 5
  • 3
8 Comments
 
LVL 47

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 47

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
 

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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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 47

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
Via a live example, show how to take different types of Oracle backups using RMAN.
This video shows how to recover a database from a user managed backup

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now