#存储过程
drop procedure if exists update_pointer;
CREATE PROCEDURE update_pointer(IN ckindId int)
BEGIN
#定义变量
DECLARE id int DEFAULT 0; #成绩ID
DECLARE score int DEFAULT 0; #成绩
DECLARE sellID int DEFAULT 0; #价格ID
DECLARE pid int DEFAULT 0; #价格ID
DECLARE upGrades int DEFAULT 0; #分数上限
DECLARE downGrade int DEFAULT 0; #分数下限
DECLARE _done tinyint(1) DEFAULT 0; #是否未找到数据标记
/* 定义光标 */
DECLARE _Cur CURSOR FOR
SELECT
t_score.id,
t_score.score,
t_score.sellID
FROM t_score
WHERE t_score.kindId = ckindId; #用户分数记录查询
DECLARE _Curprice CURSOR FOR
SELECT
t_priceinfo.id,
t_priceinfo.`upGrade`,
t_priceinfo.downGrade
FROM t_priceinfo
WHERE t_priceinfo.KindID = ckindId; #彩种价格查询
DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET _done = 1; #错误定义,标记循环结束
/*打开光标*/
OPEN _Cur;
/*循环执行*/
FETCH _Cur INTO id, score, sellID; #获取数据
WHILE _done = 0 DO #当存在数据的时候进行循环
OPEN _Curp
MySQL 存储过程游标嵌套,触发器调用存储过程
最新推荐文章于 2024-07-29 03:54:07 发布
