Dbms_metadata in a stored procedure. If the table is in the schema, run the stored procedure the procedure works very well.  If I try to get the table ddl to a different scheme it can't find table in a schema.  I run as an anonymous blocks and it works

create or replace FUNCTION get_table_md (p_owner in varchar2, p_table IN VARCHAR2) RETURN CLOB IS
-Define local variables.
/ * declare
p_owner varchar2 (30): = "AVTYM";
p_table IN VARCHAR2 (30): = "TRANSACTION_HEADER";
*/
h NUMBER; -handle returned by OPEN
e NUMBER; -handle returned by ADD_TRANSFORM
p_tableref varchar2 (30);
doc CLOB.
Doc2 CLOB.
BEGIN

-Specify the type of object.
h: = DBMS_METADATA. OPEN ('TABLE');

-Use filters to specify the desired object.
DBMS_METADATA. SET_FILTER (h, 'SCHEMA', p_owner);
DBMS_METADATA. SET_FILTER (h, 'NAME', p_table);

-Request that the metadata be transformed into creation DDL.
th: = DBMS_METADATA. ADD_TRANSFORM (h, 'DDL');

-Retrieves the object.
doc: = DBMS_METADATA. FETCH_CLOB (h);


-Free resources.
DBMS_METADATA. Close (h);
p_tableref: = substr (p_table, 1, 25). ' $RDEF';
Doc2: is REGEXP_replace(doc,p_table,p_tableref,1,1,'im');.
doc: = REGEXP_replace(doc2,'"CREATE_DT"','"EXCHANGE_DT"',1,2,'im');
-dbMS_OUTPUT. Put_line (doc);
RETURN doc;

END;

Hello

check the privilege you may have granted by a role that you need direct access to the object and not by the role. You can test if you are granted by a role, by running the SET command role no and see if you can still run the anonymous block.

Thank you

Tags: Database

Similar Questions

Maybe you are looking for

  • HP 8730w Elitebook SSD and RAM

    Hello I have a HP Elitebook 8730w and I recently installed Windows 8. I think to upgrade the RAM (from 4 GB to 8 GB) and failed hard drive (SSD). What RAM & SSD are compatible with my system? As I saw the RAM support must be • DDR2 PC2 - 6400 CL = 6

  • NET framework 1 installation fail code 0xe0434fd4

    received this code, 0xe0434fd4, after failed update of the net framework SP1 from Microsoft Update Center.  Tried reinstalling several times and received the same code. All other downloads install perfectly. correct the code number: "0xe0434f4d. Secu

  • Try to send a mail in Outlook with a large attachment are not sent after 2 days.

    original title: problem with Outlook e-mail This is not my being a strick, Windows problem, but I have a problem and do not know the answer or where to go.  I use Outlook for e-mail. I have a file of 11 stuck in my Outbox.  It seeks to be sent, but n

  • Is my Visa unregistered copy?

    The copy of Vista I have I bought a fair start, and it seems to be sealed with a good.  There is a red piece of tape coming out of the upper part of the box and a license number on a sticker on the top of the box.  Is it possible to check if the copy

  • JDE 4.5.0 Installation of Rimlet compatibility on old BB devices

    Hello I wrote a Rimlet using the JDE 4.5.0 and hit compatibility problems during the installation of the application on the BB devices. For example, try to install a 8100 Series device, I have so far also have included net_rim_xml_org.cod for the ins