日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

mysql 存储过程 显示控制_mysql存储过程之控制语句篇

發布時間:2025/4/5 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql 存储过程 显示控制_mysql存储过程之控制语句篇 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

loop的使用 要結合leave 和 iterate

看到名字 都已經大概 猜測到了 意思

leave 就是離開退出循環 而 iterate就是 繼續迭代

CREATE PROCEDURE ABC()

BEGIN

DECLARE a INT Default 0 ;

simple_loop: LOOP

SET a=a+1;

select a;

IF a=5 THEN

LEAVE simple_loop;

END IF;

END LOOP simple_loop;

END

create procedure pro

begin

declare a int default 1;

label1: loop

if a<6 then

select a;

set a=a+1;

iterate label1;

end if;

leave label1;

end loop label1;

end

3.REPEAT[begin_label:] REPEAT

statement_list

UNTIL search_condition

END REPEAT [end_label]

REPEAT語句內的語句或語句群被重復,直至search_condition為真。

create procedure pro

begin

declare a int default 3;

repeat

select a;

set a=a+1;

untile a>5 end repeat;

end

4.while

[label:] WHILE 條件 DO--循環處理END WHILE [label];

create procedure pro

begin

declare a int default 4;

while a<10 do

select a;

set a=a+1;

end while;

end

下面是一個摘抄的例子,主要看while如何使用

WHILE (id is not null ) DO

if(month='01'||month='02'||month='03') THEN set season='1';

end if;

if(month='04'||month='05'||month='06') THEN set season='2';

end if;

if(month='07'||month='08'||month='09') THEN set season='3';

end if;

if(month='10'||month='11'||month='12') THEN set season='4';

end if;

update t_industry_finance_instance set season_=season where ID_=id;

FETCH cur1 INTO id,month;

END WHILE;

總結

以上是生活随笔為你收集整理的mysql 存储过程 显示控制_mysql存储过程之控制语句篇的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。