## Examples of in-line stored database functions.

    FUNCTION Sum_Sick_Leave (emp  IN number) return number 
    AS
      tot_days  number := 0;
      CURSOR C1 IS
      SELECT sum(days) 
      FROM   sick_leave
      WHERE  emp_no = emp;
    BEGIN
      Open  C1;
      Fetch C1 into tot_days;
      Close C1;
      return (tot_days);
    END;

    FUNCTION Sum_Holiday_Leave (emp IN number) return number
    AS
      tot_days  number := 0;
      CURSOR C1 IS
      SELECT sum(days) 
      FROM   holiday_leave
      WHERE  emp_no = emp;
    BEGIN
      Open  C1;
      Fetch C1 into tot_days;
      Close C1;
      return (tot_days);
    END;

    Select E.emp_no, E.emp_name,
           sum_sick_leave(E.emp_no) sick_days, 
           sum_holiday_leave(E.emp_no) holidays
    From   emp E
    Where  E.emp_no = :emp_no
