I just want to create simple function in mysql 5.7 but getting below error ....
tried all possible ways ....but no luck....Please find the mistake.
Table :
select * from emp_tab;
+-------+---------+------+--------+
| empno | ename | sal | deptno |
+-------+---------+------+--------+ | 7101 | Martin | 4000 | 10 |
function syntax:
mysql> create function employeebonus(eno int(10))
-> returns double deterministic
-> begin
-> declare temp double;
-> declare bonus double;
-> select sal into temp from emp_tab where empno=eno;
-> if temp<=10000 then
-> set bonus=temp*0.10;
-> else if temp<=20000 then
-> set bonus=temp*0.20;
-> else
-> set bonus=temp*0.30;
-> end if;
-> return bonus;
-> end$$
at 15 th line , tried with another syntax ->end; ->$$ and ->end ->$$
but nothing got worked
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 15
error in this line ...
else if temp<=20000 then
This line should be corrected as
elseif temp<=20000 then
no space between "else if" ...its "elseif"