I need to read the structure of some database objects from an oracle database. So I want to do the following:
select dbms_metadata.get_ddl('TABLE', 'MY_TABLE', 'OTHERUSER') from dual
That works well if I'm logged in with the OTHERUSER user. But for PROD I only have a user, which has synonyms and uses this objects with that synonyms. I can select the TABLE information with the ALL_TABLES where I see that the owner is OTHERUSER, but when I run this code above with a different user, I get the following error:
ORA-31603: object "MY_TABLE" of type TABLE not found in schema "OTHERUSER"
ORA-06512: at "SYS.DBMS_METADATA", line 6069
ORA-06512: at "SYS.DBMS_METADATA", line 8666
ORA-06512: at line 1
It is exactly on the schema OTHERUSER. What can I do different to get this run? I can select from ALL_TABLES, ALL_INDEXES and so on, so I can read the information anyway, so it might not be a right problem, or am I wrong?
I know as a workaround I can use a procedure which runs in the context of OTHERUSER, but this is more than ugly.