--if
declare
avgsal number;
begin
select avg(sal) into avgsal from emp ;
if avgsal >1500 then
DBMS_OUTPUT.PUT_LINE('达到最低标准')
else
update emp1 set sal=sal+100 ;
end if;
rollback;
end ;
--case
declare
score number;
begin
score:=&成绩;
case
when score<60 then DBMS_OUTPUT.PUT_LINE('挂了');
when score between 60 and 80 then DBMS_OUTPUT.PUT_LINE('通过');
when score between 81 and 100 then DBMS_OUTPUT.PUT_LINE('优秀');
else DBMS_OUTPUT.PUT_LINE('输入错误');
end case;
end ;
--loop
declare
i number :=1;
begin
loop
i:=i+i;
DBMS_OUTPUT.PUT_LINE(i);
exit when i>10;
end loop;
end ;
--while
declare
mixsal number;
begin
select max(sal) into mixsal from emp;
while mixsal<6000
loop
update emp set sal =sal+10;
select max(sal) into mixsal from emp;
end loop;
rollback;
end ;
---for
begin
for i in 1..1000
loop
insert into dumpy values(i ,dbms_random.string('x',8),dbms_random.random());
end loop;
end ;
--goto
declare
score number;
begin
score:=&score;
if score <0 or score>100 then
goto line_1;
else
DBMS_output.put_line('正确');
return;
end if;
<>
null;-- DBMS_output.put_line('错误');
end;
本文作者:佚名 来源:本站原创
CIO之家 www.ciozj.com 微信公众号:imciow