  CREATE OR REPLACE FUNCTION "PLANTA_CALC_PRORESS" (TOTAL_COSTS NUMBER, ACTUAL_COSTS NUMBER) 
  RETURN NUMBER DETERMINISTIC IS
  returnvalue NUMBER;
BEGIN
  case 
    when coalesce(TOTAL_COSTS,0) = 0 or coalesce(ACTUAL_COSTS,0) = 0 then returnvalue := 0;
    when ACTUAL_COSTS / TOTAL_COSTS > 0 then returnvalue := ACTUAL_COSTS / TOTAL_COSTS;
    else returnvalue := 0;
  end case;
  RETURN returnvalue;
END;