반응형

       CREATE TABLE SOURCE_HIST                     -- Create history table
          AS SELECT SYSDATE CHANGE_DATE, USER_SOURCE.*
             FROM   USER_SOURCE WHERE 1=2;

        CREATE OR REPLACE TRIGGER change_hist        -- Store code in hist table
               AFTER CREATE ON SCOTT.SCHEMA          -- Change SCOTT to your schema name
        DECLARE
        BEGIN
          if DICTIONARY_OBJ_TYPE in ('PROCEDURE', 'FUNCTION',
                          'PACKAGE', 'PACKAGE BODY', 'TYPE') then
             -- Store old code in SOURCE_HIST table
             INSERT INTO SOURCE_HIST
                SELECT sysdate, user_source.* FROM USER_SOURCE
                WHERE  TYPE = DICTIONARY_OBJ_TYPE
                  AND  NAME = DICTIONARY_OBJ_NAME;
          end if;
        EXCEPTION
          WHEN OTHERS THEN
               raise_application_error(-20000, SQLERRM);
        END;
        /
        show errors

[출처] pl/sql|작성자 신머루

반응형

'Database > ORACLE' 카테고리의 다른 글

SQL LOADER 사용예  (0) 2009.03.08
PL/SQL 에서 DDL 문장 호출하기  (0) 2009.03.08
오라클 탭 출력하기  (0) 2009.03.08
오라클 패키지 백업 스크립트  (0) 2009.03.08
오라클 패키지 백업 프로그램  (2) 2009.03.08

+ Recent posts