samedi 22 octobre 2016

mysql stored procedure with the if condition gives errors

I have the following code of creating a stored procedure in mysql.

mysql>delimiter |
mysql>create procedure GetCustomerLevel()
     -> if(select count(name) from s_marks)<4
     ->  then
     ->   begin
     ->    select 'inside the if statement' as'';
     ->    select 'there are lassee than 4 students' as '';
     ->   end
     ->  else
     ->     select 'there are more than 4 stu' as '';
     ->  end if|

But it gives me this error

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 'else select 'there are more than 4 stu' as ''; end if' at line 15

what I am doing wrong? Thanks in advance

Aucun commentaire:

Enregistrer un commentaire