CREATE OR REPLACE FUNCTION wpsal ( melyik NUMBER ) RETURN NUMBER AS
  berosszeg NUMBER := 0;
  nemosztaly EXCEPTION;
BEGIN
  IF melyik NOT IN (10, 20, 30, 40) THEN
    RAISE nemosztaly;
  END IF;
  SELECT SUM(SAL) INTO berosszeg FROM EMP WHERE DEPTNO = melyik;
  RETURN berosszeg;
EXCEPTION
  WHEN nemosztaly THEN
    RETURN -1;
  WHEN OTHERS THEN
    RETURN -2;
END wpsal;
/
/*select empno, ename, job, sal, deptno, wpsal(deptno) from emp;*/