DELIMITER //
CREATE PROCEDURE p_addscore(nums INT,OUT retrows INT)
BEGIN
DECLARE i INT DEFAULT 0;
add_loop:LOOP
IF i >= nums THEN LEAVE add_loop;
END IF;
INSERT s_musicscore (ssid,uid,score,ctime,stype) VALUES(17,UUID(),8,UNIX_TIMESTAMP(),1);
SET i=i+1;
END LOOP add_loop;
SET retrows= i;
END//
DELIMITER ;
#调用
CALL p_addscore(5,@num);
#获取返回值
SELECT @num;
#删除
DROP PROCEDURE p_addscore;
时间: 2024-10-28 20:17:57