1. For 循环使用方法:
CREATE PROCEDURE ROCKY_WANG.P_FOR_ACT
(OUT V_STR VARCHAR(3000)
)
LANGUAGE SQL
p1: begin
set v_str='';
for v_emp as select ACTKWD from ROCKY_WANG.ACT do
set v_str=v_str||ltrim(rtrim(v_emp.actkwd))||';';
end for;
end p1;
2.Repeat循环使用方法:
CREATE PROCEDURE ROCKY_WANG.P_REPEAT
(OUT V_I INTEGER
)
LANGUAGE SQL
p1: begin
declare i integer default 1;
repeat_loop:
repeat
set i=i+1;
until i>=10
end repeat repeat_loop;
set v_i=i;
end p1;
3.While循环使用方法:
CREATE PROCEDURE ROCKY_WANG.P_WHILE
(OUT V_I INTEGER
)
LANGUAGE SQL
p1: begin
declare i integer default 1;
while i<10 do
set i=i+1;
end while;
set v_i=i;
end p1;
4.Loop循环使用方法:
CREATE PROCEDURE ROCKY_WANG.P_LOOP
(OUT V_I INTEGER
)
LANGUAGE SQL
p1: begin
declare i integer default 1;
fetch_loop:
loop
if i<10 then
set i=i+1;
else
leave fetch_loop;
end if;
end loop fetch_loop;
set v_i=i;
end p1;