Reputation:
I'm trying to create a function
CREATE OR REPLACE FUNCTION late_return_fee
(number_of_books IN NUMBER, days_of_late_return IN NUMBER)
RETURN DEC(4, 2)
IS
fee DEC(4,2);
BEGIN
fee := number_of_books *(days_of_late_return*0.50);
RETURN fee;
END;
/
but it come out error : Function created with compilation error. Please Help
Upvotes: 0
Views: 1238
Reputation: 191580
You can't specify any constraint for a function's return value, so you need to remove the (4,2)
from that clause:
CREATE OR REPLACE FUNCTION late_return_fee
(number_of_books IN NUMBER, days_of_late_return IN NUMBER)
RETURN DEC -- note no size constraint
IS
fee DEC(4,2);
BEGIN
fee := number_of_books *(days_of_late_return*0.50);
RETURN fee;
END;
/
Function LATE_RETURN_FEE compiled
show errors
No errors.
Not sure why you'd use DEC[IMAL]
here instead of NUMBER
and NUMBER(4,2)
.
Upvotes: 2