The code is:
DELIMITER $$
CREATE FUNCTION CHECK_AVABILITY(nama CHAR(30))
RETURNS INT(4)
DECLARE vreturn INT(4);
BEGIN
IF nama = 'ika' THEN
SET vreturn = 0;
ELSE
SET vreturn = 1;
END IF
RETURN vreturn;
END $$
The error message is:
ERROR 1064 (42000): You Have an error inyour sql syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘DECLARE vreturn INT4); BEGIN’
Help is appreciated.
Move
DECLARE vreturn INT(4)inside theBEGIN / ENDblock. You probably also need a;after theEND IF.Additionally, this looks like it is to be a
DETERMINISTICfunction. Add theDETERMINISTICkeyword before theBEGIN.