最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

MySQL游标语法实例_MySQL

来源:动视网 责编:小采 时间:2020-11-09 18:22:10
文档

MySQL游标语法实例_MySQL

MySQL游标语法实例_MySQL:bitsCN.com MySQL游标语法实例 1、基本语法: Sql代码 #定义游标 declare fetchSeqCursor cursor for select seqname, value from sys_sequence; #使用游标 open fetchSeqCursor; #fetch数据 fetch cursor int
推荐度:
导读MySQL游标语法实例_MySQL:bitsCN.com MySQL游标语法实例 1、基本语法: Sql代码 #定义游标 declare fetchSeqCursor cursor for select seqname, value from sys_sequence; #使用游标 open fetchSeqCursor; #fetch数据 fetch cursor int


bitsCN.com


MySQL游标语法实例

1、基本语法:

Sql代码

#定义游标

declare fetchSeqCursor cursor for select seqname, value from sys_sequence;

#使用游标

open fetchSeqCursor;

#fetch数据

fetch cursor into _seqname, _value;

#关闭游标

close fetchSeqCursor;

2、单游标例子:

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、嵌套的游标循环

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;

#嵌套的游标循环

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;

#嵌套的游标循环结束

end if;

end Loop;

close fetchSeqCursor;

bitsCN.com

文档

MySQL游标语法实例_MySQL

MySQL游标语法实例_MySQL:bitsCN.com MySQL游标语法实例 1、基本语法: Sql代码 #定义游标 declare fetchSeqCursor cursor for select seqname, value from sys_sequence; #使用游标 open fetchSeqCursor; #fetch数据 fetch cursor int
推荐度:
标签: 实例 mysql 游标
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top