以下是我没有修改任何记录的程序。当我在peices中运行时,一切正常。我假设我没有正确使用我的变量。谁能确认一下?谢谢。
BEGIN
DECLARE a, b, c, d, e INT;
DECLARE cur1 CURSOR FOR SELECT a.team_id, a.league_id, a.bid, f.roster_id, f.winning_team_id FROM kl_faa f, kl_faa_audit a, faa_times t WHERE t.id = f.faa_times_id AND f.id = a.faa_id AND f.auction_end_date IS NULL AND (DATE_ADD(f.last_bid_date, INTERVAL t.hours HOUR)) <= NOW() AND a.faa_id != (SELECT MAX(ref_id) FROM kl_faa_audit WHERE faa_id = a.faa_id);
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
OPEN cur1;
read_loop: LOOP
FETCH cur1 INTO a, b, c, d, e;
UPDATE kl_user_league SET cash_balance = cash_balance + @c WHERE league_id = @b and team_id = @a;
END LOOP;
CLOSE cur1;
UPDATE kl_team_roster SET team_id = @e, status = 0 WHERE roster_id = @d;
UPDATE kl_faa f LEFT JOIN faa_times t ON t.id = f.faa_times_id
SET f.auction_end_date = NOW()
WHERE t.id = f.faa_times_id AND f.auction_end_date IS NULL AND (DATE_ADD(f.last_bid_date, INTERVAL t.hours HOUR)) <= NOW();
END;
END