Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Proc Oracle that is similar to Excel FV() Function

Luiz AraujoDec 14 2011 — edited Dec 16 2011
Hi Guys.

I need to use in Oracle a function that shows me the same results that FV() financial function in Excel.

Using these parameters in Excel I got the result -29%

Rate: 1591,66
NPer: 18
PMT: 0,90083


I've been search on the web and I creat a function based on Newton-Raphson method. I'll post the source-code below.


CREATE OR REPLACE FUNCTION BI_F_FV(Rate IN NUMBER, PMT IN NUMBER, Nper IN NUMBER) RETURN NUMBER
AS

VAR_X NUMBER(12,10):= 1.50;
VAR_Y NUMBER(12,10):= 0.00;

BEGIN
WHILE TO_NUMBER(VAR_Y - 1) * 10000 <> TO_NUMBER(VAR_X - 1) * 10000 LOOP
VAR_Y:= VAR_X;
VAR_X:= VAR_Y - ((POWER(VAR_Y , (Nper + 1)) - (POWER(VAR_Y , Nper) * (PMT/Rate + 1)) + PMT/Rate) / (((Nper + 1) * POWER(VAR_Y , Nper)) - (Nper * (PMT/Rate + 1) * POWER(VAR_Y , (Nper - 1)))));
END LOOP;

RETURN (VAR_X-1);

END BI_F_FV;


But when I use the same parameters tha I had put in Excel, it shows me 0 instead -29. Anyone have a sample of FV() function in Oracle or can help me to solve this problem?

Regards.
Luiz Araujo
This post has been answered by Solomon Yakobson on Dec 16 2011
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 13 2012
Added on Dec 14 2011
3 comments
1,639 views