MySQL存储过程样例

//删除存储过程
DROP PROCEDURE IF EXISTS makeInsureAmt;

//创建存储过程
DELIMITER //
CREATE PROCEDURE makeInsureAmt(IN arg INT,IN arg2 INT)
BEGIN
DECLARE var INT;
SET var=arg;
WHILE var < arg2
DO
INSERT INTO cicp_direct_repayment_plan (applNo, lnAcct, period, dueDate, dueInsAmt, realInsAmt, duePrinAmt, realPrinAmt, dueIntAmt, realIntAmt, dueLcAmt, realLcAmt, struts, insuCompany, LocalCompany, policyNo, partnerPolicyNo, CREATEOPER, CREATETIME, MODIFYOPER, MODIFYTIME, checkFlag, checkMessage) VALUES (CONCAT('ZC00000000',var), CONCAT('JY00000000',var), 1, '2018-10-30 00:00:00', 50.00, 50.00, 2000.00, 2000.00, 25.00, 25.00, 0.00, NULL, '01', 'PA', 'YC', CONCAT('101000522201800',var), NULL, NULL, '2018-11-20 12:21:41', NULL, NULL, '1', '还款计划必传字段校验成功');
SET var = var + 1;
END WHILE;
END;
//
DELIMITER;

//调用存储过程
call makeInsureAmt(100000,100005);