-1

我正在尝试创建以下 mysql 程序,但我被困了两个小时,我不知道它有什么问题。

delimiter $$
drop procedure if exists pos_finder;
    create procedure pos_finder()
     begin
     declare below, normal, normal_h, svalue, eid, above int default 0;
     declare bcounter, ncounter, acounter int default 0;
     declare done int default 0;
     declare userData cursor for select e.id, s.value, t.below_normal_h,
t.Normal_b, t.Normal_h, t.above_normal_l from k_employee as e, k_trackers_data as s, k_trackers_sub as t where e.id = 3 and s.user_id = e.id and t.id = s.sub_tracker_id;
     declare continue handler for not found set done = 1;
     open userData;
     fetch userData into eid, svalue, below, normal, normal_h, above;
     if svalue < below then
     set bcounter = bcounter + 1;
     else if svalue > normal then
     set ncounter = ncounter + 1;
     else if svalue > above then
     set acounter = acounter + 1;
     end if;
     close userData;
     end$$

mysql 说

ERROR 1064 (42000): 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 19

这是关闭 userData线。我在这里和那里移动了换行符,它总是只在这一行上给出错误

请有人可以告诉我我在哪里做错了吗?

4

1 回答 1

0

elseif,不是else[space]if。有了一个空间,你就打开了一个全新的if街区。因此,当您接听电话时,有两个“悬空”close信号。

于 2012-11-18T03:35:43.770 回答