下面是我的触发器报错 因为本人对MySql触发器不是很熟悉,时间紧迫无法仔细查阅相关资料,所以请高手看下,应该如何修改
drop trigger tri_index_create;
create trigger tri_index_create before insert or update or delete on tb_content
for each row
begin
if insert THEN
if (select ic_id from tb_index_create where ct_id =NEW.ct_id) is null THEN
insert into tb_index_create(status,op_type,ct_id,sj_id)values(0,0,NEW.ct_id,NEW.sj_id);
else
update tb_index_create set op_type=0 and sj_id=NEW.sj_id where ct_id=NEW.ct_id;
end if;
elseif update THEN
if (select ic_id from tb_index_create where ct_id =NEW.ct_id) is null THEN
insert into tb_index_create(status,op_type,ct_id,sj_id)values(0,1,NEW.ct_id,NEW.sj_id);
else
update tb_index_create set op_type=1 and sj_id=NEW.sj_id where ct_id=NEW.ct_id;
end if;
elseif delete THEN
if (select ic_id from tb_index_create where ct_id =OLD.ct_id) is null THEN
insert into tb_index_create(status,op_type,ct_id,sj_id)values(0,2,OLD.ct_id,OLD.sj_id);
else
update tb_index_create set op_type=2 and sj_id=OLD.sj_id where ct_id=OLD.ct_id;
end if;
end if;
end;