⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 control_structures_cursors.sql

📁 《PHP和MySQL Web开发》(第三版) Source
💻 SQL
字号:
# Procedure to find the orderid with the largest amount# could be done with max, but just to illustrate stored procedure principlesdelimiter //create 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 continue handler for sqlstate '02000' set done = 1;  declare c1 cursor for select orderid, amount from orders;    open c1;  repeat    fetch c1 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 c1;   set largest_id=l_id;end//delimiter ;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -