I have cursor fetching some values from remote db and i m trying to store values in local table (see code below) I can run the select query alone succefully but when i use it inside plsql it fails with error.
DECLARE
TYPE MY_CURSOR
IS
REF
CURSOR;
THE_CURSOR MY_CURSOR;
V_CT NUMBER(18);
V_PSN_ID VARCHAR2(30);
V_INTERNET_ID VARCHAR2(75);
BEGIN
V_CT :=0;
OPEN THE_CURSOR FOR SELECT PSN_ID, 'TEST' FROM TABLE_A@PRO1 WHERE TABLE_A.SEQ_A<=1000;
LOOP
FETCH THE_CURSOR INTO V_PSN_ID, V_INTERNET_ID;
EXIT
WHEN THE_CURSOR%NOTFOUND;
INSERT INTO PSN_EMAIL_SENT_TO@local
(PSN_ID, LAST_UPDT_DT
) VALUES
(V_PSN_ID, SYSDATE
);
V_CT:=V_CT+1;
END LOOP;
CLOSE THE_CURSOR;
DBMS_OUTPUT.PUT_LINE
(
TO_CHAR(V_CT)
)
;
END;
Error report:
ORA-04052: error occurred when looking up remote object TABLE_A@PRO1
ORA-00604: error occurred at recursive SQL level 1
ORA-04029: error ORA-1775 occurred when querying ORA_KGLR7_DEPENDENCIES
ORA-00604: error occurred at recursive SQL level 1
ORA-01775: looping chain of synonyms
ORA-02063: preceding 3 lines from PRO1
04052. 00000 - "error occurred when looking up remote object %s%s%s%s%s"
*Cause: An error has occurred when trying to look up a remote object.
*Action: Fix the error. Make sure the remote database system has run
KGLR.SQL to create necessary views used for querying/looking up
objects stored in the database.