declare
  enum o_employees.eno%type;
  total number(10,2);

  function total_emp_sales(
    emp_no in  employees.eno%type)
    return number is
  sales number := 0.0;
  cursor c is
    select value(o)
    from   o_orders o
    where  o.eno = emp_no;
  od o_order_type;
  begin
    open c;
    loop
      fetch c into od;
      exit when c%notfound;
      sales := sales + od.total_cost();
    end loop;
    return (sales);
  end;

begin
  enum := 1001;
  total := total_emp_sales(enum);
  dbms_output.put_line('Total sales for employee ' || 
                         enum   || ' is ' || total);
end;
/
show errors
