ON R_SMT_ASSM_MB_T REFERENCING OLD AS OLD NEW AS NEW FOR EACH ROW
DECLARE
MESS VARCHAR2(99);
V_SEQUENCE NUMBER(10):='1';
BEGIN
SELECT SEQ_CP_PART_MAP_PK.NEXTVAL INTO V_SEQUENCE FROM DUAL;
INSERT INTO CP_SMT_ASSM_MB_T(
PK_SEQUENCE,
EMP_NO,
LOT_ID,
VERSION_CODE,
VENDER_CODE,
VENDER_PART_NO,
SELF_PART_NO,
CUST_PART_NO,
VENDER_SN,
SELF_SN,
CUST_SN,
ERROR_FLAG,
USED_FLAG,
USED_TIME,
GROUP_NAME,
STATION_NAME,
INCOMING_TIME)
VALUES(
V_SEQUENCE,
:NEW.EMP_NO,
:NEW.LOT_ID,
:NEW.VERSION_CODE,
:NEW.VENDER_CODE,
:NEW.VENDER_PART_NO,
:NEW.SELF_PART_NO,
:NEW.CUST_PART_NO,
:NEW.VENDER_SN,
:NEW.SELF_SN,
:NEW.CUST_SN,
:NEW.ERROR_FLAG,
:NEW.USED_FLAG,
:NEW.USED_TIME,
:NEW.GROUP_NAME,
:NEW.STATION_NAME,
:NEW.INCOMING_TIME);
EXCEPTION
WHEN OTHERS THEN
BEGIN
MESS:=:NEW.SELF_SN||SUBSTR(SQLERRM,1,78);
INSERT INTO R_TRIGGER_ERROR_T(TABLE_NAME,ERROR_TIME ,ERROR_MESSAGE)
VALUES('R_SMT_ASSM_MB_T',SYSDATE,MESS);
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
END;
/
SHOW ERRORS;
壹個簡單的觸發器