mysql存储过程的游标和控制结构
发布时间:2020-12-24 14:44:42 所属栏目:MySql教程 来源:网络整理
导读:今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 DELIMITER $$DROP PROCEDURE IF EXISTS `books`.`largest_order`$$CREATE DEFINER=`root`@`192.168.18.248` PROCEDURE `largest_order`(out largest_i
以下代码由PHP站长网 52php.cn收集自互联网 现在PHP站长网小编把它分享给大家,仅供参考 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 ; 以上内容由PHP站长网【52php.cn】收集整理供大家参考研究 如果以上内容对您有帮助,欢迎收藏、点赞、推荐、分享。 (编辑:淮安站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |