Pushpendra Kuntal
Pushpendra Kuntal

Reputation: 6186

Function in mysql

I am have created function in mysql.

This is code of my function

 DROP FUNCTION `star`//

CREATE DEFINER=`root`@`localhost` FUNCTION `star`(
num INT

) RETURNS int(11)
DETERMINISTIC
 BEGIN

                IF(num>=0 && num<20)
                THEN
                RETURN 1;
                ELSEIF(num>=20 && num<40)
                THEN
                RETURN 2;
                ELSEIF(num>=40 && num<60)
                THEN
                RETURN 3;
                ELSEIF(num>=60 && num<80)
                THEN
                RETURN 4;
                ELSEIF(num>=80 && num<=100)
                THEN
                RETURN 5;
                END IF;
    END

I have forgotten how did i made this function in my database. Now i want to create same function into another database.

For this i just copy above code and paste that in sql. and press Go. But it creates error. Please tell me what mistake i have done.

Upvotes: 0

Views: 302

Answers (1)

gbn
gbn

Reputation: 432210

You need a DELIMITER // statement at the top...

Upvotes: 1

Related Questions