In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
At ITPUB: http://www.itpub.net/viewthread.php? tid=1134085&pid=13049789&page=1&extra=#pid13049789 Someone posted that cursors cannot nest,
And the answer is,"I'm sorry.
[@more@]
create table heyf_6 (empid int , deptid int );
insert into heyf_6 values (1,20),(2,30),(5,20),(4,50),(6,20);
--Print EMPID in each section from small to large by DEPTID
DROP PROCEDURE IF EXISTS proc_empid;
DELIMITER //
CREATE PROCEDURE proc_empid()
BEGIN
declare done int default 0;
declare v_dept int ;
declare cur_dept cursor For select distinct deptid from heyf_6 order by deptid ;
DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;
open cur_dept;
cursor_loop:loop
fetch cur_dept into v_dept;
set @dept = v_dept;
if done=1 then leave cursor_loop ;
end if ;
select 'DEPT: ' ,v_dept ;
begin
declare done1 int default 0;
declare v_emp int;
declare cur_emp cursor For select empid from heyf_6 where deptid =@dept ;
DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done1 = 1;
open cur_emp;
cur_loop:loop
fetch cur_emp into v_emp ;
if done1=1 then leave cur_loop ;
end if ;
select '------------',@dept,v_emp ;
end loop cur_loop;
close cur_emp;
end;
end loop cursor_loop ;
close cur_dept;
END ;//
DELIMITER ;
call proc_empid;
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.