MySql 儲存過程游標使用示例

2021-05-21 21:53:33 字數 625 閱讀 9773

drop procedure if exists pro_removebillremindbyuserid;

create procedure pro_removebillremindbyuserid(userid int)

begin

declare ts varchar(500);

declare cnt int default 0;

declare f_id,b  int;

declare cur_1 cursor for select  fid from t_bill  where fuserid=userid;

declare continue handler for not found

set b = 1;

open cur_1;

repeat

fetch cur_1 into f_id;

delete from t_bill_remind where fbillid=f_id;

until b = 1

end repeat;

close cur_1;

end;

//呼叫儲存過程

call pro_removebillremindbyuserid(678);

mysql儲存過程 游標使用

1.什麼是游標 需求 編寫儲存過程,使用游標,把uid為偶數的記錄逐一更新使用者名稱。delimiter create procedure testf in my userid varchar 32 begin declare stopflag int default 0 declare my un...

SQL儲存過程游標呼叫儲存過程示例

if object id proc temp p is not null drop procedure proc temp go create procedure proc temp with recompile as select from student goexecute proc temp ...

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...