存储过程 游标
begin declare l_judge_id int default 0; declare l_cnt int default 0; declare done int default 0; declare l_cursor cursor for select judge_id from judge_court_dict ORDER BY judge_id asc; declare continue handler FOR SQLSTATE '02000' SET done = 1; open l_cursor; repeat fetch l_cursor into l_judge_id; if not done then select count(1) as cnt into l_cnt from judge_case where judge_id = l_judge_id ; update judge_court_dict set cnt=l_cnt where judge_id=l_judge_id; end if; until done end repeat; close l_cursor; END
你的指尖,有着改变世界的力量!