?
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
?
750 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 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

Free recovery tool for Microsoft Active Directory

Veeam Explorer for Microsoft Active Directory provides fast and reliable object-level recovery for Active Directory from a single-pass, agentless backup or storage snapshot — without the need to restore an entire virtual machine or use third-party tools.

Question has a verified solution.

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

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…
How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
This video shows how to recover a database from a user managed backup
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.
Suggested Courses

850 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