3
我想知道這個觸發器有什麼問題。我是新的MySQL觸發器和存儲過程,所以我猜可能有語法錯誤。mysql觸發器中的語法錯誤
-- Trigger DDL Statements
DELIMITER $$
USE `SNPB`$$
DROP TRIGGER IF EXISTS getMsnps$$
CREATE TRIGGER getMsnps AFTER INSERT ON m_snps
FOR EACH ROW
BEGIN
DECLARE glid int(10);
DECLARE lost int(1);
DECLARE st int(10);
DECLARE vto varchar(20);
IF(EXISTS(SELECT glyc_id FROM glyc WHERE glyc_start<=NEW.uni_pos AND glyc_end>=NEW.uni_pos AND glyc.uni_prot_ac=NEW.uni_prot_ac)) THEN
SELECT glyc_id,glyc_start INTO glid,st FROM glyc WHERE glyc_start<=NEW.uni_pos AND glyc_end>=NEW.uni_pos AND glyc.uni_prot_ac=NEW.uni_prot_ac;
SELECT all_snps.var_to INTO vto FROM all_snps,snp_map WHERE snp_map.snpb_id=NEW.snpb_id AND snp_map.ref>0 AND snp_map.all_snps_id=all_snp.all_snps_id;
set lost=0;
IF NEW.uni_pos=st AND vto!='n' AND vto!='N' THEN
set lost=1;
END IF;
IF NEW.uni_pos=st+1 AND (vto='p' OR vto='P') THEN
set lost=1;
END IF;
IF NEW.uni_pos=st+2 AND vto!='s' AND vto!='S' AND vto!='t' AND vto!='T' THEN
set lost=1;
END IF;
INSERT INTO glyc_map (glyc_id,snpb_id,loss) VALUES (glid,NEW.snpb_id,lost);
END IF;
END;
$$
DELIMITER ;
所以,當我在表中插入行「m_snps」(多行是通過一個單獨的語句插入)我應該得到一些行中的「glyc_map」表但從未發生過。我希望有人能告訴我語法是對還是錯。
你得到一個錯誤1064,但有什麼錯誤信息? – 2012-03-20 03:05:34
@ ta.speot.is「DELIMITER」語句僅針對MySQL命令行客戶端,而不是整個RDBMS實現的必要特性。 – 2012-03-20 03:18:30
我沒有收到任何錯誤!這真是讓我難過。一切似乎都很好。 – user1279904 2012-03-20 03:20:29