develog

[Oracle] Trigger 생성 본문

DB/Oracle

[Oracle] Trigger 생성

냐옴 2015. 6. 19. 17:03

CREATE OR REPLACE TRIGGER TG_ATEST_B_UD

BEFORE UPDATE OR DELETE ON ATEST

REFERENCING OLD AS O NEW AS N

FOR EACH ROW

DECLARE

    V_LOG_TYPE CHAR(1);

BEGIN


    IF UPDATING THEN V_LOG_TYPE := 'U'; END IF;

    IF DELETING THEN V_LOG_TYPE := 'D'; END IF;


    INSERT INTO ATEST_HIST

    (

          SEQ

        , TITLE

        , CONTENT

        , LOG_TS

        , LOG_TYPE

    )

    VALUES

    (

          :O.SEQ

        , :O.TITLE

        , :O.CONTENT

        , SYSTIMESTAMP

        , V_LOG_TYPE

    );


END;



'DB > Oracle' 카테고리의 다른 글

[Oracle] NLS parameters  (0) 2015.08.04
[Oracle] time zone  (0) 2015.08.04
[Oracle] REF CURSOR  (0) 2015.06.18
[Oracle] DDL, DML, DCL, TCL  (0) 2015.05.13
[Oracle] 부여된 권한 조회  (0) 2015.01.21
Comments