21 January 2009

How to unload package script from Oracle?

You do not have PL/ SQL with you, but you need to know the script of one of the packages inside your Oracle database.

So, I believe you will need the below sample codes:



Declare
     i Integer;
     fFileOpened utl_file.file_type;
     cClob Clob;
Begin
     For X In (Select u.Object_Name From User_Objects u Where upper(u.Object_name) = 'YOUR_PACKAGE_NAME') Loop
         fFileOpened := prime_files.Openf(aLocation => 'YOUR_ORACLE_DIRECTORY', aFilename => x.Object_Name || '.sql', aOpenMode => 'w');
         cClob := Dbms_Metadata.get_ddl('PACKAGE', x.Object_Name);
         i := prime_files.WriteClob2File(aClob_loc => cClob, aOutFile => fFileOpened);
         Prime_Files.Closef(aFile => fFileOpened);
     End Loop;
End;
/

No comments: