Commands out of sync; you can't run this command now?

postfix2 2011-11-28 03:06:07
CREATE PROCEDURE `procUserlogin`(
out o_userid int,
out o_userstep int,
out o_usernichen varchar(50),
in i_userName varchar(50),
in i_userPasword varchar(50))
NOT DETERMINISTIC
CONTAINS SQL
SQL SECURITY DEFINER
COMMENT ''
begin

set @sqlstr = concat("select @o_userid := user_id from user_list where user_loginname='",i_userName,"'");
prepare sqlstmt from @sqlstr;
execute sqlstmt;
DEALLOCATE PREPARE sqlstmt;
set o_userid = @o_userid;

if o_userid = 0 then
set o_userid = -2;
else
set o_userid=0;
set @sqlstr = concat("select @o_userid := user_id from user_list where user_loginname='",i_userName,"' and user_password='",i_userPasword,"'");

prepare sqlstmt from @sqlstr;
execute sqlstmt;
DEALLOCATE PREPARE sqlstmt;
set o_userid = @o_userid;
if @o_userid = 0 then
set o_userid = -1;
else
set @sqlstr = concat("select @o_userstep:=user_state,@o_usernichen:=user_nichenname from user_list where user_id=",o_userid);
prepare sqlstmt from @sqlstr;
execute sqlstmt;
DEALLOCATE PREPARE sqlstmt;
set o_userstep = @o_userstep;
set o_usernichen = @o_usernichen;

end if;
end if;

我的存储过程在EMS SQL Manage下测试没有问题,在PHP下调用就出现了:
===============================================================================
Commands out of sync; you can't run this command now?
...全文
714 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
postfix2 2011-11-28
  • 打赏
  • 举报
回复
Result consisted of more than one row?
postfix2 2011-11-28
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 wwwwa 的回复:]
直接在SP中运行SQL语句试试
select user_id into @o_userid from user_list where user_loginname=i_userName
[/Quote]

非常感谢,into @o_userid 可以取得值 @o_userid:=就会出错,请问原因?
postfix2 2011-11-28
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 wwwwa 的回复:]
直接在SP中运行SQL语句试试
select user_id into @o_userid from user_list where user_loginname=i_userName
[/Quote]

谢谢回复user_id into @o_userid 可以传回值?

WWWWA 2011-11-28
  • 打赏
  • 举报
回复
直接在SP中运行SQL语句试试
select user_id into @o_userid from user_list where user_loginname=i_userName
postfix2 2011-11-28
  • 打赏
  • 举报
回复
set @sqlstr = concat("select @o_userid := user_id from user_list where user_loginname='",i_userName,"'");
prepare sqlstmt from @sqlstr;
execute sqlstmt;
DEALLOCATE PREPARE sqlstmt;
set o_userid = @o_userid;

postfix2 2011-11-28
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 acmain_chm 的回复:]
排除一些语句,看看是哪一句导致这个问题。
[/Quote]

谢谢指点,发现动态查询有问题,是不是我的写的动态SQL语句的组合有问题?
ACMAIN_CHM 2011-11-28
  • 打赏
  • 举报
回复
排除一些语句,看看是哪一句导致这个问题。

56,677

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧