您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

mysql存储过程的游标和控制结构

2025/2/12 7:23:36发布53次查看
通过该段代码理解mysql存储过程的游标和控制结构 mysql delimiter $$drop procedure if exists `books`.`largest_order`$$create definer=`root`@`192.168.18.248` procedure `largest_order`(out largest_id int)begin declare this_id int; declare this_am
通过该段代码理解mysql存储过程的游标和控制结构 mysql delimiter $$drop procedure if exists `books`.`largest_order`$$create definer=`root`@`192.168.18.248` procedure `largest_order`(out largest_id int)begin declare this_id int; declare this_amount float; declare l_amount float default 0.0; declare l_id int; declare done int default 0; declare cl cursor for select orderid,amount from orders; declare continue handler for sqlstate '02000' set done =1; open cl; repeat fetch cl into this_id,this_amount; if not done then if this_amount > l_amount then set l_amount = this_amount; set l_id = this_id; end if; end if; until done end repeat; close cl; set largest_id = l_id;end$$delimiter ;
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product