MySQL?洢??????????????
?????BuleSky ???????[ 2016/11/17 11:20:09 ] ????????MySQL ?????
?????????????????????BEGIN…END?????BEGIN…END?β????????DELIMITER($$)????????????????ú????;??β??????????????????????
???????????
??????洢?????????У???????ù??????????????????????????e?????????????OPEN??FETCH??CLOSE????????????£?
????<1>???????
????DECLARE cursor_name CURSOR FORselect_statement
????<2>?????
????OPEN cursor_name
????<3>??ù??
????FETCH cursor_name INTO var_name[??var_name]…
????<4> ?????
????CLOSE cursor_name
???????5????emp??????н????????????????deptno???????salary??????ж????????????????NOT FOUND????????FETCH?????????????????????????????????????
????DELIMITER $$
????CREATE PROCEDURE dept_salary_sum()
????BEGIN
????DECLAREi_dept_no int;
????DECLAREi_salary int(5);
????DECLAREcur_emp CURSOR FOR SELECT deptno??salary FROM emp;
????DECLAREEXIT HANDLER FOR NOT FOUND CLOSE cur_emp;
????SET@salary_sum_dept1=0;
????SET@salary_sum_dept2=0;
????OPENcur_emp;
????REPEAT
????FETCHcur_emp INTO i_dept_no??i_salary;
????IFi_dept_no=1 THEN
????SET@salary_sum_dept1=@salary_sum_dept1+i_salary;
????ELSE
????SET@salary_sum_dept2=@salary_sum_dept2+i_salary;
????ENDIF;
????UNTIL0 END REPEAT;
????CLOSEcur_emp;
????END $$
????DELIMITER ;
????CALL dept_salary_sum();
????SELECT @salary_sum_dept1??@salary_sum_dept2;
????->50000 27000
????????????????????????????????DECLARE?????????????????????????????????????????????????????????????????????????????????????????
???????????
???????????IF??CASE??LOOP??LEAVE??ITERATE??REPEAT??WHILE???????????????????????????ο?????汾???????5.6?汾??
????http://dev.mysql.com/doc/refman/5.6/en/flow-control-statements.html
????IF???
????IF search_condition THEN statement_list
????[ELSEIF search_condition THEN statement_list] ...
????[ELSE statement_list]
????END IF
????CASE???
????CASE case_value
????WHEN when_value THEN statement_list
????[WHEN when_value THEN statement_list] ...
????[ELSE statement_list]
????END CASE
????????
????CASE
????WHEN search_condition THEN statement_list
????[WHEN search_condition THEN statement_list] ...
????[ELSE statement_list]
????END CASE
????????????????У?IF???????????CASE?????????
????CASE
????WHEN i_dept_no =1 THEN
????SET@salary_sum_dept1=@salary_sum_dept1+i_salary;
????ELSE
????SET@salary_sum_dept2=@salary_sum_dept2+i_salary;
????END CASE;
?????????
????CASE i_dept_no
????WHEN 1 THEN
????SET@salary_sum_dept1=@salary_sum_dept1+i_salary;
????ELSE
????SET @salary_sum_dept2=@salary_sum_dept2+i_salary;
????END CASE;
????LOOP???
????[begin_label:] LOOP
????statement_list
????END LOOP [end_label]
????LOOP???????????????????????????????????????壬??????????LEAVE??????????????statement_list????????????????????LOOP???????????????????????
???????6????LOOP???
????CREATE PROCEDURE doiterate(p1 INT)
????BEGIN
????label1: LOOP
????SETp1 = p1 + 1;
????IFp1 < 10 THEN
????ITERATE label1;
????ENDIF;
????LEAVE label1;
????ENDLOOP label1;
????SET@x = p1;
????END;
????LEAVE???
????LEAVE label
?????????????????????????????????BEGIN…END????????????á?????????????
????ITERATE???
????ITERATE label
????ITERATE??????????????У?????????????????????μ????????????????????????????????
????REPEAT???
????[begin_label:] REPEAT
????statement_list
????UNTIL search_condition
????END REPEAT [end_label]
??????????????????????????????????????????????????5?????REPEAT????????????????á?
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????
??????
?????????????????????????Щ????????????????????TC???????????????Щ???????????????????????????????????????????????(java .net ?????)???mysql???????????????????ж????д???Python???????????????(DB2)??????BufferPool????????????????????????????????6??????????????????滮???????????????-????????SQL Server???????????????????λ?????PHP??SQL????????????????????Pythonд???NoSQL????????? SQL ?е????????????? SQL ?е?????????Java???????:?????MySQL???????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11????????
?????????App Bug???????????????????????Jmeter?????????QC??????APP????????????????app?????е????????jenkins+testng+ant+webdriver??????????????JMeter????HTTP???????Selenium 2.0 WebDriver ??????