-- xmlmeta.sql

CREATE OR REPLACE FUNCTION get_xml_meta(tablename VARCHAR2)
  RETURN clob
IS
   handle NUMBER;
   doc CLOB;
BEGIN
   handle := DBMS_METADATA.OPEN('TABLE');
   DBMS_METADATA.SET_FILTER(handle,'SCHEMA',USER);
   DBMS_METADATA.SET_FILTER(handle,'NAME',tablename);
   doc := DBMS_METADATA.FETCH_CLOB(handle); 
   DBMS_METADATA.CLOSE(handle);
   RETURN doc;
END;  
/
