DB2存储过程4类循环简单实例

更新时间:2023-06-22 12:39:21 阅读: 评论:0

DB2存储过程4类循环简单实例SET SCHEMA = 'DB2ADMIN';
SET CURRENT PATH = "SYSIBM","SYSFUN","SYSPROC","SYSIBMADM","DB2ADMIN"; CREATE PROCEDURE "DB2ADMIN"."TEST_CIRCULATION" ( )
DYNAMIC RESULT SETS 1
LANGUAGE SQL
NOT DETERMINISTIC
EXTERNAL ACTION
MODIFIES SQL DATA
OLD SAVEPOINT LEVEL
p1: begin
declare aa varchar(10);
declare bb varchar(10);贾斯丁比伯的歌曲
declare a integer DEFAULT 0;
-- 定义⼀个全局临时表tmp_hy
declare global temporary p_hy
(
dm varchar(10),
mc varchar(10)
)
with replace -- 如果存在此临时表,则替换
not logged;  -- 不在⽇志⾥纪录
-- 给临时表插⼊三条数据
inrt p_hy values('1','01');
journal
inrt p_hy values('2','02');
inrt p_hy values('3','03');
瑞思英语怎么样
--for隐式循环
for cur1 as lect dm,mc p_hy
do
if cur1.dm='1' or cur1.dm='2' or cur1.dm='3' then
inrt p_hy ,'隐式循环');
end if;
p_hy t mc='0'||''||'' where dm=cur1.dm;
end for;
透传p2: begin
-
-简单循环
declare cursor2 cursor for
lect dm,mc p_hy;
OPEN cursor2;
FETCH_LOOP: LOOP
FETCH cursor2 INTO aa,bb;
pokkiIF a >= 3 THEN    -- loop until last row of the cursor
2020高考真题试卷LEAVE FETCH_LOOP;
END IF;
if aa='1' or aa='2' or aa='3' then
inrt p_hy values(bb,'简单循环');
end if;
t a=a+1;
END LOOP FETCH_LOOP;
clo cursor2;
end p2;
t a=0;cansitive
p3: begin
--进⼊前检查条件
declare cursor2 cursor for
lect dm,mc p_hy;
OPEN cursor2;
FETCH cursor2 INTO aa, bb;
while a<3
do
if aa='1' or aa='2' or aa='3' thenforever意思
inrt p_hy values(bb,'while循环');
end if;
t a=a+1;
校训英文
FETCH cursor2 INTO aa, bb;
end while;
clo cursor2;
end p3;
t a=0;
p4: begin暑假补习班
--退出前检查条件
declare cursor2 cursor for
lect dm,mc p_hy;
OPEN cursor2;
REPEAT
FETCH cursor2 INTO aa, bb;
if aa='1' or aa='2' or aa='3' then
inrt p_hy values(bb,'REPEAT循环');  end if;
t a=a+1;
UNTIL a>=3
end REPEAT;
clo cursor2;
end p4;
p5: begin
--声明游标
declare cursor1 cursor with return for
lect * p_hy;
--游标对客户机应⽤程序保持打开
open cursor1;
end p5;
end p1;

本文发布于:2023-06-22 12:39:21,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/90/153708.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:循环   客户机   程序   保持
相关文章
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图