--包头
create or replace package pkg_caculate_soccer
AS
FUNCTION GET_result(p1 in number,p2 in number)
return number;
procedure p_main_3(a1 in number,a2 in number,b1 in number,b2 in number,c1 in number,c2 in number);
procedure p_main_4(a1 in number,a2 in number,b1 in number,b2 in number,c1 in number,c2 in number
,d1 in number,d2 in number);
procedure p_main_5(a1 in number,a2 in number,b1 in number,b2 in number,c1 in number,c2 in number
,d1 in number,d2 in number,e1 in number,e2 in number );
end pkg_caculate_soccer;
--包体
create or replace package body pkg_caculate_soccer
AS
R1 NUMBER;
R2 NUMBER;
R3 NUMBER;
R4 NUMBER;
R5 NUMBER;
FUNCTION GET_result(p1 in number,p2 in number) RETURN NUMBER IS
y NUMBER;
x number;
BEGIN
x:=dbms_random.value(0,100);
y:=case when x>0 and x<=p1 then 3 when x>p1 and x<=p2+p1 then 1 else 0 end;
RETURN y;
END GET_result;
procedure p_main_3(a1 in number,a2 in number,b1 in number,b2 in number,c1 in number,c2 in number
) as
i number;
begin
--create table p_main_3(id1 number,id2 number,id3 number);
execute immediate 'truncate table p_main_3';
for i in 1..100 loop
R1 :=get_result(a1,a2);
R2 :=GET_RESULT(b1,b2);
R3 :=GET_RESULT(c1,c2);
insert into p_main_3 values(R1,R2,R3);
--dbms_output.put_line(R1||' '||R2||' '||R3);
end loop;
commit;
for p3 in (
select * from (select id1,id2,id3,COUNT(*) icount from p_main_3 group by id1,id2,id3 order by icount desc) where rownum <= 10)
loop
dbms_output.put_line(p3.id1||' '||p3.id2||' '||p3.id3||' 出现的次数为: '||p3.icount);
end loop;
end p_main_3;
procedure p_main_4(a1 in number,a2 in number,b1 in number,b2 in number,c1 in number,c2 in number
,d1 in number,d2 in number) as
i number;
begin
--create table p_main_4(id1 number,id2 number,id3 number,id4 number);
execute immediate 'truncate table p_main_4';
for i in 1..100 loop
R1 :=GET_RESULT(a1,a2);
R2 :=GET_RESULT(b1,b2);
R3 :=GET_RESULT(c1,c2);
R4 :=GET_RESULT(D1,D2);
insert into p_main_4 values(R1,R2,R3,R4);
end loop;
commit;
for p4 in (
select * from (select id1,id2,id3,id4,COUNT(*) icount from p_main_4 group by id1,id2,id3,id4 order by icount desc) where rownum <= 10)
loop
dbms_output.put_line(p4.id1||' '||p4.id2||' '||p4.id3||' '||p4.id4||' 出现的次数为: '||p4.icount);
end loop;
end p_main_4;
procedure p_main_5(a1 in number,a2 in number,b1 in number,b2 in number,c1 in number,c2 in number
,d1 in number,d2 in number,e1 in number,e2 in number ) as
i number;
begin
--create table p_main_5(id1 number,id2 number,id3 number,id4 number,id5 number);
execute immediate 'truncate table p_main_5';
for i in 1..100 loop
R1 :=get_result(a1,a2);
R2 :=GET_RESULT(b1,b2);
R3 :=GET_RESULT(c1,c2);
R4 :=GET_RESULT(D1,D2);
R5 :=GET_RESULT(e1,e2);
insert into p_main_5 values(R1,R2,R3,R4,R5);
end loop;
commit;
for p5 in (
select * from (select id1,id2,id3,id4,id5,COUNT(*) icount from p_main_5 group by id1,id2,id3,id4,id5 order by icount desc) where rownum <= 10)
loop
dbms_output.put_line(p5.id1||' '||p5.id2||' '||p5.id3||' '||p5.id4||' '||p5.id5||' 出现的次数为: '||p5.icount);
end loop;
end p_main_5;
END PKG_CACULATE_SOCCER;