Re: pl/sql Question

From: Daniel Morgan <damorgan_at_exxesolutions.com>
Date: Wed, 23 Apr 2003 13:26:57 -0700
Message-ID: <3EA6F710.19DD4A5A_at_exxesolutions.com>


Harsh Kohli wrote:

> I have to compute a value within pl/sql using a formula stored in
> another user table so that user's can change the formula without
> changing the code. The formula looks like :
> [SH1 value +SH2 value)/TOT1 * 100 * W1] + [SH3 value+SH4 value)/TOT2
> * 100 * W2] + [SH5 value+SH6 value)/TOT3 * 100 * W3] + ......
>
> where SH* Value comes from a table which has the following 2 columns :
> SH Code SH Value
>
> example :
> SH1 94
> SH2 198
> SH3 218
> SH4 782
> .....
>
> The TOT* and W* comes from 2 different tables.
>
> What is the best way to store this formula in a table and how can I
> execute with pl/sql?

Store it in a table with two columns. One column identifying the formula element the other with the formula value.

Then write your code using native dynamic SQL to stitch it all together on-the-fly at execution time.

--
Daniel Morgan
http://www.outreach.washington.edu/extinfo/certprog/oad/oad_crs.asp
(remove one 'x' from my email address to reply)
Received on Wed Apr 23 2003 - 22:26:57 CEST

Original text of this message