문서의 이전 판입니다!
CREATE OR REPLACE TRIGGER 트리거이름 FOR 트리거링 이벤트 ON 테이블명 COMPOUND TRIGGER -- 전역 변수 선언 g_global_variable VARCHAR2(10); TYPE TYPE_SALED_TAB IS TABLE OF SALED%ROWTYPE; G_SALED_TAB TYPE_SALED_TAB := TYPE_SALED_TAB(); TYPE ty_bookings_hist IS TABLE OF bookings_hist%rowtype INDEX BY pls_integer; coll_bookings_hist ty_bookings_hist; ctr pls_integer := 0; BEFORE STATEMENT IS --명령문 레벨 트리거 BEFORE BEGIN NULL; -- Do something here. END BEFORE STATEMENT; BEFORE EACH ROW IS --행레벨 트리거 BEFORE BEGIN NULL; -- Do something here. END BEFORE EACH ROW; AFTER EACH ROW IS --행레벨 트리거 AFTER BEGIN IF INSERTING OR UPDATING OR DELETING THEN G_SALED_TAB.EXTEND; NULL; END IF; ctr := ctr + 1; dbms_output.put_line('In after each row. booking_id='||:NEW.booking_id); coll_bookings_hist(ctr).booking_id := :NEW.booking_id; coll_bookings_hist(ctr).mod_dt := sysdate; coll_bookings_hist(ctr).mod_user := USER; coll_bookings_hist(ctr).old_booking_dt := :OLD.booking_dt; coll_bookings_hist(ctr).new_booking_dt := :NEW.booking_dt; NULL; -- Do something here. END AFTER EACH ROW; AFTER STATEMENT IS --명령문 레벨 트리거 AFTER BEGIN IF G_SALED_TAB.COUNT() > 0 THEN FOR i IN G_SALED_TAB.first .. G_SALED_TAB.last LOOP END LOOP; END IF; forall counter IN 1..coll_bookings_hist.count() INSERT INTO bookings_hist VALUES coll_bookings_hist(counter); NULL; -- Do something here. END AFTER STATEMENT; END <trigger-name>;