2
CREATE DEFINER=`root`@`localhost` PROCEDURE `Mobile_ForgotPassword`(IN`v_email` VARCHAR(30), IN `v_valid` INT)
NO SQL
IF (v_valid = 0) THEN
    SELECT email FROM user_registration WHERE email = v_email;
ELSE
    SELECT password FROM user_registration WHERE email = v_email;
END IF;

I have this MySQL Stored procedure and its not working. Whenever i try to execute this script on phpmyadmin, getting error on line 4 that i have syntax error. As i am using phpmyadmin, delimiter already added dynamically and i have a privileges to root account. I tried removing DEFINER but still it isn't working. As per my knowledge, i am not seeing any syntax error in script or i am not getting it. Anyone ?

2 Answers 2

1
CREATE DEFINER=`root`@`localhost` PROCEDURE `Mobile_ForgotPassword`(IN `v_email` VARCHAR(30), IN `v_valid` INT) 
NO SQL 
IF (v_valid = 0) THEN 
    SELECT email FROM user_registration WHERE email = v_email LIMIT 1;
ELSE 
SELECT password FROM user_registration WHERE email = v_email LIMIT 1; 
END IF;
  1. Removed default Delimiter from textbox under script editor in phpMyAdmin
Sign up to request clarification or add additional context in comments.

Comments

0

You need to add DELIMITER

DELIMITER |
    CREATE PROCEDURE `Mobile_ForgotPassword`(IN`v_email` VARCHAR(30), IN `v_valid` INT)
    NO SQL
    IF (v_valid = 0) THEN
        SELECT email FROM user_registration WHERE email = v_email;
    ELSE
        SELECT PASSWORD FROM user_registration WHERE email = v_email;
    END IF;
    |
    DELIMITER ;

4 Comments

Nope. Tried that and failed. And as i already mentioned, i am using phpmyadmin to run this Procedure and phpmyadmin adds delimiter itself
it's working fine in my phpmyadmin as well as sqlyog. you just copy and paste in you sql editor and run query.
Ok, let me try again.
I tried to run the script you gave me. It did create the procedure with this error : '#1064 - 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 'DELIMITER' at line 1'. phpmyadmin shows procedure in list but with not query in it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.