1 --procedure 1: get the average of hisal(out parameter)
2 create or replace procedure getAvgHisal
3 (v_average out salgrade.hisal%type)
4 as
5 begin
6 select AVG(hisal) into v_average
7 from salgrade;
8 end;
9
10 set serveroutput on;
11 declare
12 v_average number := 0;
13 begin
14 getAvgHisal(v_average);
15 dbms_output.put_line(v_average);
16 end;
17
18 --procedure 2: get the hisal according to the grade
19 create or replace procedure getHisalAccording
20 (inGrade in salgrade.grade%type, outHisal out salgrade.hisal%type)
21 as
22 begin
23 select hisal into outHisal
24 from salgrade
25 where grade = inGrade;
26 end;
27
28 set serveroutput on;
29 declare
30 outHisal salgrade.hisal%type := 0;
31 begin
32 getHisalAccording(1,outHisal);
33 dbms_output.put_line(outHisal);
34 end;
2 create or replace procedure getAvgHisal
3 (v_average out salgrade.hisal%type)
4 as
5 begin
6 select AVG(hisal) into v_average
7 from salgrade;
8 end;
9
10 set serveroutput on;
11 declare
12 v_average number := 0;
13 begin
14 getAvgHisal(v_average);
15 dbms_output.put_line(v_average);
16 end;
17
18 --procedure 2: get the hisal according to the grade
19 create or replace procedure getHisalAccording
20 (inGrade in salgrade.grade%type, outHisal out salgrade.hisal%type)
21 as
22 begin
23 select hisal into outHisal
24 from salgrade
25 where grade = inGrade;
26 end;
27
28 set serveroutput on;
29 declare
30 outHisal salgrade.hisal%type := 0;
31 begin
32 getHisalAccording(1,outHisal);
33 dbms_output.put_line(outHisal);
34 end;