Monday, 3 October 2011

create package and execute packages

create or replace package pkg_test1
    is
        function getArea (i_rad NUMBER) return NUMBER;
        procedure p_print (a in number,b in number,c out number);
    end pkg_test1;

--------------------------------------
create or replace package body pkg_test1
    is
        function getArea (i_rad NUMBER)return NUMBER
        is
          v_pi NUMBER:=3.14;
       begin
          return v_pi * (i_rad ** 2);
       end;

       procedure p_print(a in number,b in number,c out number)
       is
       begin
           c:=a+b;
       end;
   end;
   ------------------------------------------
   \
   --execution of packages:
   declare
   a NUMBER; 
   i number;
   g number;
   h number;
   begin
   a:=pkg_test1.getarea(&num);
   pkg_test1.p_print(&g,&h,i);
   dbms_output.put_line('the area value is='||a||'********'||i||g);
   end;

No comments:

Post a Comment