----Backup With Procedure
---Create Directory
CREATE OR REPLACE DIRECTORY PS_DIR AS '/u01/oracle/PROD/fs2/EBSapps/appl/au/12.0.0/forms/BackUp';
---Create Procedure
CREATE OR REPLACE PROCEDURE EXPORT_DDL
AS
V_DDL_CLOB CLOB;
VPATH VARCHAR2(255);
BEGIN
FOR C IN (SELECT OBJECT_NAME,
OBJECT_TYPE
FROM USER_OBJECTS
WHERE OBJECT_TYPE IN ('TABLE','VIEW','FUNCTION','PROCEDURE','PACKAGE','PACKAGE_BODY')
and OBJECT_NAME like '%TGC%')
LOOP
V_DDL_CLOB :=
DBMS_METADATA.GET_DDL(C.OBJECT_TYPE, C.OBJECT_NAME);
DBMS_XSLPROCESSOR.CLOB2FILE(V_DDL_CLOB, 'PS_DIR', C.OBJECT_TYPE || '_' || C.OBJECT_NAME||'.SQL');
END LOOP;
END;
--- Call procedure
Exec EXPORT_DDL;