PL / SQL 포두 와 패키지

                  ,             ,            

  ,     , SQL*PLUS          CREATE PACKAGE  。

    :
CREATE OR REPLACE PACKAGE emp_pkg IS
  PROCEDURE update_sal(name VARCHAR2,newsal NUMBER);
  FUNCTION annual_incom(name VARCHAR2) RETURN NUMBER;
  END;

              ,             。                ,

 SQL*PLUS         CREATE PACKAGE BODY  。    :
CREATE OR REPLACE PACKAGE BODY EMP_PKG IS
PROCEDURE update_sal(name VARCHAR2,newsal NUMBER)
  IS
 BEGIN 
   UPDATE EMP set sal=newsal
   where lower(ename)=lower(name);
   end;
FUNCTION annual_incom(name VARCHAR2) return number
  IS
  annual_salary NUMBER(7,2);
  begin
    select sal*12 + nvl(comm,0) INTO annual_salary
    from emp where lower(ename)=lower(name);
    RETURN annual_salary;
    end;
    end;


           ,                    (  .    ),

            ,            (   .  .    ).

SQL> set serveroutput on
SQL> exec emp_pkg.update_sal('scott',1500);

PL/SQL procedure successfully completed.

SQL> select emp_pkg.annual_incom('scott') from dual;

EMP_PKG.ANNUAL_INCOM('SCOTT')
-----------------------------
			18000















좋은 웹페이지 즐겨찾기