Jul 4, 2016

Extracting Wrapped PL/SQL Code from Database

Background



When Wrapped PL/SQL Code is deployed in Oracle Database ,  you cannot simply retrieve the code using tools like Toad. Just copying the code from Schema Browser does not work. 

Solution 


This can be achieved using  SYS.DBMS_METADATA.GET_DDL function.    See the sample below. 

--Run as  SYSTEM user 

SELECT DBMS_METADATA.GET_DDL('PACKAGE’,’P_EMPLOYEE’,’SCOTT' ) FROM dual;

SELECT DBMS_METADATA.GET_DDL('PACKAGE_BODY’,’P_EMPLOYEE’,’SCOTT' ) FROM dual;

--Note This was tested on Oracle 10g database