Reputation: 735
I am trying to create a login in SQL and using stored procedures to capture the login information.
Even when executing the stored procedure on phpmyadmin, my out param is always returning Null, and I can't figure out why.
userid
is my OUT param, I am getting back an email and password and the rest of the fields are empty strings.
BEGIN
set @userid = (select id from `user` where `email` = email and `password` = password and statusId = 8);
if @userid is not null
then
set @statu = 9;
elseif @userid is null
then
set @statu = 10;
end if;
call loginHistory(@userid, email, @statu, ip4, ip6, deviceType, appVer);
set @userid = userid;
END
Thanks
Upvotes: 0
Views: 67
Reputation: 142208
Change
set @userid = userid;
to
SET userid = @userid;
userid
and @userid
are different things.
If that does not suffice, show us the rest of the declaration.
Upvotes: 1
Reputation: 1269503
You have a problem with your parameters. Name them with a prefix, such as in
.
So I think you want:
BEGIN
select @user_id := u.id
from `user`u
where u.email = in_email and
u.password = in_password and
u.statusId = 8;
set @statu = (case when @userid is not null then 9 else 10 end);
call loginHistory(@userid, in_email, @statu, in_ip4, in_ip6, in_deviceType, in_appVer);
set @userid = in_userid;
END;
I'm not sure if this will fix your problem, but at least the code will do something more sensible.
Upvotes: 0