基础知识(1)


--if then elsif then end if;
declare
a number;
b varchar2(10);
begin
a := 2;
if a=1 then
b :='a';
elsif a=2 then
b := 'b';
else
b := 'c';
end if;
Dbms_Output.put_line('b is '|| b);
end;
--case when
declare
a number;
b varchar2(10);
begin
a := 2;
case
when a=1 then b := 'a';
when a=2 then b := 'b';
when a=3 then b := 'c';
else
b := 'others';
end case;
dbms_output.put_line('b is '|| b);
end;

--loop end loop
declare
x number;
begin
x := 0;
loop
x := x+ 1;
if x >=3 then
exit;
end if;
dbms_output.put_line('内:x='||x);
end loop;
dbms_output.put_line('外:x='||x);
end;

--exit when 方式
declare
x number;
begin
x:= 0;
loop
x:=x+1;
exit when x>=3;
dbms_output.put_line('内:x='||x);
end loop;
dbms_output.put_line('外:x='||x);
end;

begin
for i in reverse 1..5 loop
dbms_output.put_line('i='||i);
end loop;
dbms_output.put_line('end of for loop');
end;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值