DBlink Issue ORA-00942 table or view does not exist
Sven W.Jun 20 2008 — edited Jun 20 2008I am about to tune a long running function. One of the first steps was to put this function into a package and this seemed to cause the following problem.
ORA-00942: table or view does not exist
ORA-02063: preceding line from <DBLINK>
The reason (I guess) is this:
Inside the function a select on a remote table is made via DB-Link.
However this is not a table but a synonym pointing to Table1.
From time to time (every 3 hours) this synonym is switched from Table1 to Table2 and back. The reason is that in this table are some aggregated data that is recalculated every 3 hours.
It seems that because of this table switching I get the "ORA-00942: table or view does not exist" error.
I already tried as a workaround to create a view on the locate DB, but that didn't help. I'm now trying the select dynamically (execute immediate) but I would prefere another way.
Can somebody explain why I get the error with a packaged function and not with a standalone function and is there some workaround on this?