CREATE PROCEDURE userinfo_modify(
IN id INT
,IN loginid INT
,IN levelid INT
,IN namestr VARCHAR(50)
,IN tel VARCHAR(50)
,IN account VARCHAR(50)
)
BEGIN
set @lid=loginid;
set @lvid=levelid;
set @n=namestr;
set @t=tel;
set @a=account;
set @uid=id;
select @eid=IFNULL(loginid,0) from userinfo where loginid=@lid; if (IFNULL(@eid,0)=0)
Then
Insert into userinfo(loginid,levelid,namestr,tel,account)
VALUES(@lid,@lvid,@n,@t,@a);
select last_insert_id();
ELSE
update userinfo
SET loginid =@lid
,levelid=@lvid
,namestr=@n
,tel =@t
,account=@a
where id=@uid;
END IF;
END