00000 – “trigger ‘%s.%s’ is invalid and failed re-validation” 오류 해결



📍 “trigger ‘%s.%s’ is invalid and failed re-validation”



📌 문제 발생


SQL
-- 테이블 생성 SQL - tbl_user
CREATE TABLE tbl_user
(
    user_idx          NUMBER(20)      NOT NULL, 
    user_name         VARCHAR2(30)    NOT NULL, 
    user_email        VARCHAR2(30)    NOT NULL, 
    user_pw           VARCHAR2(30)    NOT NULL, 
    user_sign_date    DATE            DEFAULT SYSDATE NOT NULL, 
    user_position     VARCHAR2(10)    DEFAULT '0' NOT NULL, 
     PRIMARY KEY (user_idx)
);

-- Auto Increment를 위한 Sequence 추가 SQL - tbl_user.user_idx
CREATE SEQUENCE tbl_user_SEQ
START WITH 1
INCREMENT BY 1;

-- Auto Increment를 위한 Trigger 추가 SQL - tbl_user.user_idx
CREATE OR REPLACE TRIGGER tbl_user_AI_TRG
BEFORE INSERT ON tbl_user 
REFERENCING NEW AS NEW FOR EACH ROW 
BEGIN 
    SELECT tbl_user_SEQ.NEXTVAL
    INTO :NEW.user_idx
    FROM DUAL;
END;

INSERT INTO tbl_user (user_email, user_pw, user_name) VALUES ('email', 'pw', 'name');




📌 오류 해석




📌 오류 해결


SQL
-- Auto Increment를 위한 Sequence 추가 SQL - tbl_user.user_idx
CREATE SEQUENCE tbl_user_SEQ
START WITH 1
INCREMENT BY 1;

-- Auto Increment를 위한 Trigger 추가 SQL - tbl_user.user_idx
CREATE OR REPLACE TRIGGER tbl_user_AI_TRG
BEFORE INSERT ON tbl_user 
REFERENCING NEW AS NEW FOR EACH ROW 
BEGIN 
    SELECT tbl_user_SEQ.NEXTVAL
    INTO :NEW.user_idx
    FROM DUAL;
END;





numeric precision specifier is out of range (1 to 38) 오류 해결