---关于Oracle里面的循环
-- while循环
CREATE OR REPLACE
function while_test(x in number,y in number)
return number is
z number;
totalCount number;
begin
z:=x;
totalCount:=0;
while z<y+1
loop
delete USERTEMP where id=z;
z:=z+1;
totalCount:=totalCount+1;
end loop;
return totalCount; --结果为6
end;
--for 循环
CREATE OR REPLACE
function for_test(x in number)
return number is
z number;
begin
z:=0;
for v_sum in 1..50
loop
z:=z+2;
end loop;
return z;
end;
--单循环
CREATE OR REPLACE
function perfunctory_test(x in number)
return number
is z number;
begin
loop
z:=x*x; --实现函数(x)的平方
exit;
end loop;
return z;
end;
--- 注意事项 :mysql 里面的循环和Oracle里面的不一样,声明,赋值都不一样。这里吃了大亏,自己一直在写MySQL的语句,所以运行不成功。
-- 【Mysql】的while循环语句
declare @i int
set @i=1
while @i<10
begin
insert into USERTEMP(id,name,CARDTYPE,CARDNO,status) VALUES(@i,'李','学生','01',2);
set @i=@i+1
end
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。