久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

MySQL游標(biāo)語法的用法

157次閱讀
沒有評論

共計(jì) 1635 個(gè)字符,預(yù)計(jì)需要花費(fèi) 5 分鐘才能閱讀完成。

本篇內(nèi)容主要講解“MySQL 游標(biāo)語法的用法”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實(shí)用性強(qiáng)。下面就讓丸趣 TV 小編來帶大家學(xué)習(xí)“MySQL 游標(biāo)語法的用法”吧!

1、基本語法:
Sql 代碼
#定義游標(biāo)
declare fetchSeqCursor cursor for select seqname, value from sys_sequence;
#使用游標(biāo)
open fetchSeqCursor;
#fetch 數(shù)據(jù)
fetch cursor into _seqname, _value;
#關(guān)閉游標(biāo)
close fetchSeqCursor;
2、單游標(biāo)例子:
Sql 代碼
## define the flag for loop judgement
declare fetchSeqOk boolean;
## define the varient for store the data
declare _seqname varchar(50);
declare _value bigint(20);
## define the cursor
declare fetchSeqCursor cursor for select seqname, value from sys_sequence;
## define the continue handler for not found flag
declare continue handler for NOT FOUND set fetchSeqOk = true;
set fetchSeqOk = false;
open fetchSeqCursor;
fetchSeqLoop:Loop
if fetchSeqOk then
leave fetchSeqLoop;
else
fetch cursor into _seqname, _value;
select _seqname, _value;
end if;
end Loop;
close fetchSeqCursor;
3、嵌套的游標(biāo)循環(huán)
Java 代碼
## define the flag for loop judgement
declare fetchSeqOk boolean;
## define the varient for store the data
declare _seqname varchar(50);
declare _value bigint(20);
## define the cursor
declare fetchSeqCursor cursor for select seqname, value from sys_sequence;
## define the continue handler for not found flag
declare continue handler for NOT FOUND set fetchSeqOk = true;
set fetchSeqOk = false;
open fetchSeqCursor;
fetchSeqLoop:Loop
if fetchSeqOk then
leave fetchSeqLoop;
else
fetch cursor into _seqname, _value;
#嵌套的游標(biāo)循環(huán)
begin
declare fetchSeqOk boolean default inner
## define the cursor
declare cursor2 cursor for select …. from …;
## define the continue handler for not
declare continue handler for NOT FOUND set fetchSeqOk = true;
set fetchSeqOk = false;
open cursor2;
fetchloop2 loop
if fetchSeqOk then
else
end if;
end loop;
close cursor2;
end;
#嵌套的游標(biāo)循環(huán)結(jié)束
end if;
end Loop;
close fetchSeqCursor;

到此,相信大家對“MySQL 游標(biāo)語法的用法”有了更深的了解,不妨來實(shí)際操作一番吧!這里是丸趣 TV 網(wǎng)站,更多相關(guān)內(nèi)容可以進(jìn)入相關(guān)頻道進(jìn)行查詢,關(guān)注我們,繼續(xù)學(xué)習(xí)!

正文完
 
丸趣
版權(quán)聲明:本站原創(chuàng)文章,由 丸趣 2023-08-01發(fā)表,共計(jì)1635字。
轉(zhuǎn)載說明:除特殊說明外本站除技術(shù)相關(guān)以外文章皆由網(wǎng)絡(luò)搜集發(fā)布,轉(zhuǎn)載請注明出處。
評論(沒有評論)
主站蜘蛛池模板: 宜章县| 平阳县| 济源市| 章丘市| 嘉义县| 乌苏市| 甘孜| 调兵山市| 富民县| 太保市| 嘉兴市| 宜兰县| 华宁县| 集安市| 贵南县| 莱阳市| 大兴区| 虞城县| 历史| 嵩明县| 晋中市| 崇左市| 秦皇岛市| 邹平县| 纳雍县| 丰台区| 辽宁省| 无棣县| 旌德县| 襄城县| 鹤峰县| 雷山县| 江达县| 聊城市| 双鸭山市| 苏州市| 久治县| 进贤县| 鹰潭市| 霸州市| 惠水县|