问题出在mysql过程中。我想在mysql过程中运行一个更新查询。我已经创建了该过程并调用它,没有任何错误。但问题是过程中的update查询没有被执行。
delimiter $$
create procedure update_member_status(IN new_mem_id int,IN mem_count int)
begin
declare tot_ref_count,mem_ref_id int default 0;
select ref_id into mem_ref_id
from ccf_user
where user_id=new_mem_id;
select ref_count into tot_ref_count
from ccf_user
where user_id=mem_ref_id;
if tot_ref_count = mem_count then
update ccf_user
set status='permanent'
where user_id=mem_ref_id;
else
update ccf_user
set status='*****'
where user_id=mem_ref_id;
end if;
end
$$然后我调用了这个过程:-调用update_member_status(25,6)
我希望执行过程中的更新查询
发布于 2013-09-07 18:26:34
我将从将此过程重写为一条SQL语句开始:
UPDATE ccf_user c1, ccf_user c2
SET c1.status =
CASE WHEN c1.ref_count = @mem_count
THEN 'permament' ELSE '*****' END
WHERE c1.user_id = c2.ref_id
AND c2.user_id = @new_mem_id
;然后分析它是否提供了预期的结果,例如使用以下命令:http://www.sqlfiddle.com/#!2/2310b/1
https://stackoverflow.com/questions/18670752
复制相似问题