文章目录
1、创建一个程序包(包名称用户自拟),其功能有:
(1)求数n的阶乘。
(2)求数n的前n项之和
程序包
create or replace package Demo_1
is
procedure Demo_jiechen(n int);
procedure Demo_nums(n int);
end Demo_1;
程序包体
create or replace package body Demo_1 is
procedure Demo_jiechen(n int) is
i int:=1;
lasts int:=1;
begin
loop
lasts:=lasts*i;
i:=i+1;
exit when i>n;
end loop;
dbms_output.put_line(lasts);
end Demo_jiechen;
procedure Demo_nums(n int) is
i int:=1;
lasts int:=0;
begin
loop
lasts:=lasts+i;
i:=i+1;
exit when i>n;
end loop;
dbms_output.put_line(lasts);