create procedure sp1()
begin
declare s int default 0;
declare f_total int;
declare f_playerid varchar(30);
declare cur cursor for select count(*) as total ,playerid from ff_soccer_lottery_prize_record where ff_soccer_lottery_prize_record.lottery_date < '2016-06-10 15:07:22' group by playerid order by total desc;
declare continue handler for sqlstate '02000' set s=1;
open cur;
fetch cur into f_total, f_playerid;
while s <> 1 do
update ff_soccer_lottery set ff_soccer_lottery.lottery_used_count = ff_soccer_lottery.lottery_used_count - f_total where ff_soccer_lottery.playerid = f_playerid;
fetch cur into f_total, f_playerid;
end while;
close cur;
end;
call sp1;
drop procedure sp1;
mysql儲存過程以及游標的使用 handler結束標誌的使用貌似必須在變數定義的下面,不然會報錯
#設定乙個終止標記
declare continue handler for sqlstate '02000' set s=1
#開啟游標就不說了
fetch cur into f_total, f_playerid #這裡注意,變數的使用必須在上面用declare定義型別
mysql 儲存過程 游標的使用
儲存過程 create procedure changefrozen begin 定義變數 declare i int default 0 declare d int default 0 declare y id int declare y uid int declare y task id int...
mysql儲存過程,對游標的操作
create procedure p delete test teacher in t id bigint,out res code int begin 定義游標結束標記 declare done int default 0 定義臨時儲存變數儲存遍歷右邊的id declare tmp id bigi...
mysql儲存過程游標的運用,適合對游標剛學習者。
近來,因業務的需要寫了乙個儲存,放上面曬曬。適合對游標剛學習者,大致業務是實現對多張表審核操作需要插入審核訊息記錄 建立帶有三個輸入引數,乙個輸出引數的儲存 create procedure prop dealmessage in ids integer in status1 integer in ...