Re: how to use plsql to calculate compond growth

From: David <ning_1898_at_yahoo.com>
Date: 30 Dec 2003 07:40:04 -0800
Message-ID: <37032184.0312300740.31267d87_at_posting.google.com>


Frank van Bortel <fvanbortel_at_netscape.net> wrote in message news:<bsq16n$4g1$1_at_news2.tilbu1.nb.home.nl>...
> Ken Denny wrote:
>
> > null_pointer_at_rediffmail.com (nullpointer) wrote in
> > news:c0728f9d.0312282347.59b6f551_at_posting.google.com:
> >
> >
> >>PL SQL autobinds so no need to specify those as bind variables
> >>This should work
> >>
> >> 1 declare
> >> 2 money number :=50000.00;
> >> 3 year number :=1;
> >> 4 begin for i in 1..17
> >> 5 loop insert into my_401k values(year, money + 0.1*money);
> >> 6 year := year +1;
> >> 7 end loop;
> >> 8* end;
> >>
> >>Hope it Helps
> >>nullpointer
> >
> >
> > That will get around the error message, but it won't give you the results
> > you're looking for. Note: you never changed the value of the variable
> > money, so every year money is going to have 55000.00 in the moey column.
> >
> 1 declare
> 2 money number := 50000.00;
> 3 year number := 1;
> 4 begin
> 5 for i in 1..17
> 6 loop
> 7 money := money *1.1;
> 8 execute immediate 'insert into my_401k values (:y,:m)'
> 9 using year, money;
> 10 year := year + 1;
> 11 end loop;
> 12* end;
>
> SQL> col money for 999,999,990.00
> SQL> select * from my_401k;
>
> YEAR MONEY
> ---------- ---------------
> 1 55,000.00
> 2 60,500.00
> 3 66,550.00
> 4 73,205.00
> 5 80,525.50
> 6 88,578.05
> 7 97,435.86
> 8 107,179.44
> 9 117,897.38
> 10 129,687.12
> 11 142,655.84
>
> YEAR MONEY
> ---------- ---------------
> 12 156,921.42
> 13 172,613.56
> 14 189,874.92
> 15 208,862.41
> 16 229,748.65
> 17 252,723.51
>
> 17 rows selected.

Frank,

How about if I add 12000 anually to my account? How to calculate that?

Best Regards,

David Received on Tue Dec 30 2003 - 16:40:04 CET

Original text of this message