0

我试图将数据库中的值存储到过程内部的变量中,并将其值增加 1。这就是我所做的:

CREATE DEFINER=`satish`@`%` PROCEDURE `p_authTeacher`(
IN username VARCHAR(35),
IN pwd VARCHAR(35),
OUT msg INT,  
OUT msg1 INT,
OUT msg2 INT
)
BEGIN
select (COUNT(*) > 0) INTO @result from login where User_Name = username and    User_Password = md5(pwd);

SET msg = @result;  
IF @result = 1 THEN
select (COUNT(*)>0) into @result1 from login where User_Name = username and User_Password = md5(pwd) and Is_New ='F';
if @result1= 1 Then
UPDATE login SET Last_login=now() where User_Name = username and User_Password = md5(pwd);
SET msg1 = @result1;
END IF;
if @result1= 0 Then
UPDATE login SET Last_login=now() where User_Name = username and User_Password = md5(pwd);
SET msg1 = @result1;    
END IF;
END IF; 
IF @result = 0 THEN
    select Password_Attempts into @attempts from login where User_Name = username ;
    SET msg2 = @attempts;
update login set Password_Attempts=1 where username = uname;
END IF;
END

试图存储列(密码尝试)的值,其中用户名 = 登录表的名称。将 1 添加到其中并更新到数据库中。但当然我得到了语法错误。请帮助我。即使用户名和密码不匹配,最后一个 if 块也不起作用。

4

1 回答 1

1

请参阅链接以获取正确的语法SELECT ... INTO。你应该INTOFROM

select Password_Attempts into @attempts from login where User_Name = uname ;
于 2013-06-28T07:12:00.057 回答