2010-01-24 4 views
1

미리 정의 된 시퀀스에서 ID를 설정하는 트리거를 만들려고합니다.삽입 트리거 오류 생성

CREATE SEQUENCE seq_list_status 
    START WITH 1 
    INCREMENT BY 1 

; 

CREATE OR REPLACE TRIGGER trg_list_status_insert 
    BEFORE INSERT ON list_status 
    FOR EACH ROW 
    select seq_list_status.nextval into :new.id from dual; 
/

나는 내가 그것을 봤 트리거

Error starting at line 1 in command: 
CREATE OR REPLACE TRIGGER trg_list_status_insert 
    BEFORE INSERT ON list_status 
    FOR EACH ROW 
    select seq_list_status.nextval into :new.id from dual 
Error at Command Line:4 Column:4 
Error report: 
SQL Error: ORA-04079: invalid trigger specification 
04079. 00000 - "invalid trigger specification" 
*Cause: The create TRIGGER statement is invalid. 
*Action: Check the statement for correct syntax. 

을 만드는 동안 아래의 오류 받고 있어요하지만 모든 확인을 보인다. 무엇이 잘못 될 수 있는지에 대한 아이디어가 있습니까?

답변

5

당신은 beginend

CREATE OR REPLACE TRIGGER trg_list_status_insert 
BEFORE INSERT ON list_status 
FOR EACH ROW 
BEGIN 
select seq_list_status.nextval into :new.id from dual; 
END; 
/
누락
6

트리거는 프로그램 단위입니다. 따라서 BEGIN 및 END에 코드 본문을 래핑해야합니다. 사용해보기

CREATE OR REPLACE TRIGGER trg_list_status_insert 
    BEFORE INSERT ON list_status 
    FOR EACH ROW 
BEGIN 
    select seq_list_status.nextval into :new.id from dual; 
END; 
/

불행히도 the examples in the SQL Reference은 우리가 원하는만큼 도움이되지 않습니다. 그러나 the App Developers Guide과 같은 다른 유용한 문서로 연결됩니다.