This results in an ORA-00923: From keyword not found
error:
create or replace function gr_pay_hrly (p_wage_rate IN Number,
p_hrs_worked In number)
Return Number IS
t_wage pay_history.wage_rate%type;
t_hours pay_history.hrs_worked%type;
t_gross_pay number(10,2);
BEGIN
select wage_rate into t_wage,
hrs_worked into t_hours
from pay_history
where wage_rate = p_wage_rate
and hrs_worked = p_hrs_worked;
IF t_hours >= 40 THEN
t_gross_pay := (((t_hours - 40) * t_wage) * 1.5);
ELSE
t_gross_pay := t_hours * t_wage;
END IF;
RETURN t_gross_pay;
END;
/
Your issue is the
INTO
clause -- it's only declared once in a statement:The population of variables is based on the order of the columns declared in the SELECT clause.
Full re-write:
If you subtract 40 from the
hours_worked
with is also 40, you'll just be multiplying by zero. And you want to add the straight time payout to the overtime...