//1.
命令行书写方法:
declare
num number:=1;
a number default 2;
begin
a:=num+1;
dbms_output.put_line(a);
end;
判断身高年龄
declare
height number:=185;
weight number default 150;
begin
if height>180 then
dbms_output.put_line('你很高');
elsif weight<160 then
dbms_output.put_line('你很瘦');
end if;
end;
/
//3.
declare
i number:=1;
summ number:=0;
begin
while i<=100 loop
summ:=summ+i;
i:=i+1;
end loop;
dbms_output.put_line(summ);
end;
/
//4
declare
summ number:=0;
begin
for i in 1..100 loop (i in 1..10就是i=1;i<=100)
summ:=summ+i;
end loop;
dbms_output.put_line(summ);
end;
/
//5.
begin
for i in reverse 1..10 loop
dbms_output.put_line(i);
end loop;
end;
/
//6.
declare
i number:=1;
summ number:=0;
begin
loop
summ:=summ+i;
i:=i+1;
exit when i>100;
end loop;
dbms_output.put_line(summ);
end;
/
//7.存储过程
create procedure getsumm
is
summ number:=0;
begin
for i in 1..50 loop
summ:=summ+i;
end loop;
dbms_output.put_line(summ);
end;
/
//8.带参数的存储过程也就是方法;这里面也可以写sql语句
create procedure getArea(width number,height number)
is
area number:=0;
begin
area:=width*height;
dbms_output.put_line('面积为'||area);
end;
/