db_link name and synonym in PL/SQL block
88657Nov 13 2006 — edited Aug 3 2012Hi,
I'm having a problem with synonyms in PL/SQL block.
Say, I have two schemas A and B.
In schema A, I create some tables and stored procedures.
In schema B, I create a db link connecting to schema A. Then I create some synonyms for tables and stored procedures in schema A with the db link. In stored procedures created in schema B, I need to access or reference objects in schema by using synonyms.
My problem is, if schema A and schema B reside on the same db instance and the instance's global_names is set to true, I will not be able to reference any synonyms in stored procedures created in schema B. The error message is,
PL/SQL: ORA-00980: synonym translation is no longer valid.
A simple example:
In schema A,
create table mytable (A char(2));
In schema B,
create database link <global_name-for-schema-A>@loopback connect to A identified by <A-pwd> using '<net-service-name-for-schema-A>';
create synonym mytable for mytable@<global_name-for-schema-A>@loopback;
declare
a char;
begin
select * from mytable;
end;
/
But I have no problem to access the synonym-ed objects in SQL*PLUS.
Please help.
Thanks