2017-10-06 9 views
0

MySql 5.1.41에서 트리거 문을 실행하려고하는데 내 이해가 부족한 오류가 발생합니다. 어떤 도움을 주시면 감사하겠습니다.MySql 트리거 구문 오류 1064 빈 작은 따옴표

create TRIGGER populate_modality_trigger AFTER INSERT on series 
FOR EACH ROW BEGIN 
DECLARE x int; 

select count(*) into x from lu_modality_alias l WHERE l.modality=NEW.modality; 
IF (x =0 OR x is NULL) THEN 
    INSERT INTO lu_modality_alias 
    set modality = NEW.modality, 
    modality_alias = NEW.modality 
; 
END if; 
end; 

나는 위의 코드를 실행, 나는 다음과 같은 얻을 오류 : 다음

트리거 코드

MySQL said: Documentation #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 3

흥미로운 점은 그 내가 Naviacat 쿼리 편집기에서 동일한 코드를 실행할 때 , 성공적으로 실행되고 트리거가 생성됩니다. 그러나 phpMyAdmin sql에서도 같은 오류가 발생합니다.

+2

에서 구문 분석 CREATE 문을 종료하지 않도록 구분 기호 문자를 변경해야합니다. 첫번째 ; 문제가 해결되었습니다 –

+0

덕분에 많은, CREATE 문을 끝내고있다 –

답변

2

당신은 MySQL을 파서가 첫 번째 세미콜론 당신이 당신의 구분 기호를 변경해야

delimiter // 

create TRIGGER populate_modality_trigger AFTER INSERT on series 
FOR EACH ROW BEGIN 
DECLARE x int; 

select count(*) into x from lu_modality_alias l WHERE l.modality=NEW.modality; 
IF (x =0 OR x is NULL) THEN 
    INSERT INTO lu_modality_alias 
    set modality = NEW.modality, 
    modality_alias = NEW.modality 
; 
END if; 
end // 

delimiter ; 
+0

고마워, Garr, 내 문제가 해결되었습니다 –