Mysql存储过程问题

时间:2017-04-21 06:57:59

标签: mysql

我是MySQL存储过程的新手。我写了登录验证,但它不起作用。

CREATE PROCEDURE `Login_validation`(
IN `Username` VARCHAR(50),
IN `password` VARCHAR(50)) 
  LANGUAGE SQL
  NOT DETERMINISTIC
  CONTAINS SQL
  SQL SECURITY DEFINER
  COMMENT ''
   BEGIN

        IF EXISTS(SELECT * FROM user_details where FIRSTNAME=@Username) THEN
            BEGIN
                    IF EXISTS(SELECT * FROM user_details where FIRSTNAME=@Username and Password=@password) THEN
                         BEGIN
                             SELECT 'SUCCESS' STATUSDISCRTIPTION, '100' STATUSCODE;
                      END;
                    ELSE
                            BEGIN
                                    SELECT 'USERNAME AND PASSWORD NOT MATCHING' STATUSDISCRTIPTION, '101' STATUSCODE;
                            END;
                    END IF; 
            END;
        ELSE
                BEGIN
                            SELECT 'USERNAME NOT EXISTS' STATUSDISCRTIPTION , '101' STATUSCODE;
                END;
        END IF;
    END 

这是我的存储过程,我得到SELECT'USERNAME NOT EXISTS'STATUSDISCRTIPTION,'101'STATUSCODE;这个输出只。如果循环不起作用。

call Login_validation('Malathi','123456')

malathi名字在表中。有什么问题?

1 个答案:

答案 0 :(得分:0)

符号@username用于用户变量,不要与存储过程参数混淆。

使用where FIRSTNAME = Username