MySql 存储过程及调用方法

存储过程实例:

DELIMITER $$
drop procedure if exists ff $$
CREATE

/*[DEFINER = { user | CURRENT_USER }]*/
PROCEDURE ff()
/*LANGUAGE SQL
| [NOT] DETERMINISTIC
| { CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL DATA }
| SQL SECURITY { DEFINER | INVOKER }
| COMMENT 'string'*/
BEGIN
declare i integer;
declare am integer;
declare idx integer;
set idx=512;
set am=100;
set i=0;
while i<303 do
begin

if idx != 612
then
update mgrcapitaldf set balance=balance+am*i where id=idx;
set i = i +1;
end if;

set idx = idx+1;

end;
end while;

END$$

DELIMITER ;

-- 调用方法:

call ff();

原文地址:https://www.cnblogs.com/spplus/p/5950075.html