Re: how to use plsql to calculate compond growth

From: Jim Kennedy <kennedy-downwithspammersfamily_at_attbi.net>
Date: Sun, 28 Dec 2003 07:15:32 GMT
Message-ID: <oqvHb.682774$Fm2.590452_at_attbi_s04>


"David" <ning_1898_at_yahoo.com> wrote in message news:37032184.0312271915.d9d43ef_at_posting.google.com...
> I am learning plsql. I would like to run a stored procedure to
> calculate my bank account value by predicted 10% annual growth rate.
> Below is my plsql that is having problems. Your help is highly
> appreciated.
>
> Thanks
>
> declare
> money number := 50000.00;
> year number := 1;
> begin for i in 1..17
> loop
> execute immediate 'insert into my_401k values (':year', 'money + 0.10
> * money')';
> year := year + 1;
> end loop;
> end;
> /
>
>
> SP2-0552: Bind variable "YEAR" not declared.
>
> Any where wrong in this script?
>
> Thanks

Much simpler and more efficient to:(no need for execute immediate)
> declare
> money number := 50000.00;
> year number := 1;
> begin for i in 1..17
> loop
 insert into my_401k values (:year, :money + 0.10* :money);
> year := year + 1;
> end loop;
> end;
> /
>
Received on Sun Dec 28 2003 - 08:15:32 CET

Original text of this message