delimiter//
create procedure exercise(out stat char(10),out fee double)
begin
if stat=='AC executive' then set fee=100;
else if stat=='AC Economi' then set fee=50;
else set saldo=20;
end if;
end//
delimiter;
答案 0 :(得分:0)
您的if-else if
不正确,应该是
if condition then do something
elseif condition then do something
else do something
elseif
之间没有空格。另外,我想你的意思是fee
而不是saldo
。 out stat char(10)
应为in stat varchar(100)
,因为您使用参数作为输入
delimiter //
create procedure exercise(in stat varchar(100),out fee double)
begin
if stat ='AC executive' then set fee=100;
elseif stat = 'AC Economi' then set fee=50;
else set fee=20;
end if;
end;//
delimiter;
这是对mysql的测试
mysql> delimiter //
mysql> create procedure exercise(in stat varchar(100),out fee double)
-> begin
-> if stat ='AC executive' then set fee=100;
-> elseif stat = 'AC Economi' then set fee=50;
-> else set fee=20;
-> end if;
-> end;//
Query OK, 0 rows affected (0.00 sec)
mysql> delimiter ;
mysql> call exercise('AC executive',@o);
Query OK, 0 rows affected (0.00 sec)
mysql> select @o ;
+------+
| @o |
+------+
| 100 |
+------+
1 row in set (0.00 sec)