create procedure stc_info(in Tid char(8), in type int, out info varchar(10)) BEGIN IF type = 1 then set info = CAST((select count(Tno) from stc where Tno=Tid group by Tno) AS CHAR); ELSEIF type = 2 then set info = CAST((select AVG(Score) from stc where Tno=Tid group by Tno) AS CHAR); ELSE set INFO = 'error!!!'; end if; END;语句错误 提示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 7
时间: 2024-02-10 20:07:45 浏览: 174
pcb-2020-10-21_STC8G1K08A_stc8g_STC8Goled_pcb
5星 · 资源好评率100%
这个错误可能是因为存储过程中的语句没有以分号结尾。请尝试将代码修改如下:
```
create procedure stc_info(in Tid char(8), in type int, out info varchar(10))
BEGIN
IF type = 1 then
set info = CAST((select count(Tno) from stc where Tno=Tid group by Tno) AS CHAR);
ELSEIF type = 2 then
set info = CAST((select AVG(Score) from stc where Tno=Tid group by Tno) AS CHAR);
ELSE
set INFO = 'error!!!';
end if;
END;
```
在存储过程中,应该使用 BEGIN 和 END 来标记代码块的开始和结束。此外,SQL 语句应该以分号结尾。在这个存储过程中,每个 SQL 语句都已经以分号结尾,但是在最后的 END 后面也要加上分号,以表示存储过程的结束。
阅读全文