while creating a procedure in MYSQL i am facing a problem as, condition runs 'IF' statement and runs 'ELSE' statements too. just because an insert statement inside 'IF'.
insert into Userverified (UserID, Mobile, PIN,uname,unameid)
select NextUserID(),Mobile,PIN,null,null from UserNotVerified where Mobile=p_Mobile;
always results--- "result 00" ---why?
if i remove this
insert into Userverified (UserID, Mobile, PIN,uname,unameid)
select NextUserID(),Mobile,PIN,null,null from UserNotVerified where Mobile=p_Mobile;
works fine.
im using PhpMyAdmin and new with MYsql. code attached here as---
CREATE procedure test
(
p_Mobile varchar(13),
p_LastOTP varchar(6)
)
begin
if ((select count(*) from UserVerified where mobile=p_Mobile)=0)
then
insert into Userverified (UserID, Mobile, PIN,uname,unameid)
select NextUserID(),Mobile,PIN,null,null from UserNotVerified where Mobile=p_Mobile;
if((select count(*) from uwallet where mobile=p_Mobile)=0)
then
insert into UserWallet (WalletID,Mobile,JoinAmount,WinAmount,ReferAmount,TotalAmount,DateModified)
select nextwalletid(),p_Mobile,0,0,0,0,now();
end if;
select 1 as result;
else
select '00' as result;
end if;
end;