SET PAGESIZE 0 FEEDBACK OFF HEADING OFF LINESIZE 5000
SET LONG 10000000 LONGCHUNKSIZE 10000000

SPOOL D:\ORACLE_EXPORT\dumps\SYS_OBJECTS.sql

-- Export DDL pentru obiectele SYS custom
SELECT '-- SYS.AUTH_PACK Package Spec' FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('PACKAGE','AUTH_PACK','SYS') FROM DUAL WHERE EXISTS (SELECT 1 FROM dba_objects WHERE owner='SYS' AND object_name='AUTH_PACK');
SELECT '/' FROM DUAL;

SELECT '-- SYS.AUTH_PACK Package Body' FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('PACKAGE BODY','AUTH_PACK','SYS') FROM DUAL WHERE EXISTS (SELECT 1 FROM dba_objects WHERE owner='SYS' AND object_name='AUTH_PACK' AND object_type='PACKAGE BODY');
SELECT '/' FROM DUAL;

SELECT '-- SYS.NEWSCHEMA Procedure' FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('PROCEDURE','NEWSCHEMA','SYS') FROM DUAL WHERE EXISTS (SELECT 1 FROM dba_objects WHERE owner='SYS' AND object_name='NEWSCHEMA');
SELECT '/' FROM DUAL;

SELECT '-- SYS.NEWSCHEMAJOB Procedure' FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('PROCEDURE','NEWSCHEMAJOB','SYS') FROM DUAL WHERE EXISTS (SELECT 1 FROM dba_objects WHERE owner='SYS' AND object_name='NEWSCHEMAJOB');
SELECT '/' FROM DUAL;

SELECT '-- SYS.NEWSCHEMAPROGRESS Function' FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('FUNCTION','NEWSCHEMAPROGRESS','SYS') FROM DUAL WHERE EXISTS (SELECT 1 FROM dba_objects WHERE owner='SYS' AND object_name='NEWSCHEMAPROGRESS');
SELECT '/' FROM DUAL;

SELECT '-- SYS.UPDATESQLPLUS Procedure' FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('PROCEDURE','UPDATESQLPLUS','SYS') FROM DUAL WHERE EXISTS (SELECT 1 FROM dba_objects WHERE owner='SYS' AND object_name='UPDATESQLPLUS');
SELECT '/' FROM DUAL;

SELECT '-- SYS.EXECUTESCRIPTOS Procedure' FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('PROCEDURE','EXECUTESCRIPTOS','SYS') FROM DUAL WHERE EXISTS (SELECT 1 FROM dba_objects WHERE owner='SYS' AND object_name='EXECUTESCRIPTOS');
SELECT '/' FROM DUAL;

SELECT '-- SYS.VAUTH_SERII View' FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('VIEW','VAUTH_SERII','SYS') FROM DUAL WHERE EXISTS (SELECT 1 FROM dba_objects WHERE owner='SYS' AND object_name='VAUTH_SERII');
SELECT '/' FROM DUAL;

SELECT '-- SYS.AUTH_SERII Table' FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('TABLE','AUTH_SERII','SYS') FROM DUAL WHERE EXISTS (SELECT 1 FROM dba_tables WHERE owner='SYS' AND table_name='AUTH_SERII');
SELECT '/' FROM DUAL;

SELECT '-- SYS.AUTH_DETALII Table' FROM DUAL;
SELECT DBMS_METADATA.GET_DDL('TABLE','AUTH_DETALII','SYS') FROM DUAL WHERE EXISTS (SELECT 1 FROM dba_tables WHERE owner='SYS' AND table_name='AUTH_DETALII');
SELECT '/' FROM DUAL;

SPOOL OFF
EXIT;
