I need to build a mathematical equation in a .p at run time that is based upon data the user entered in a setup maintenance application. The user inputs might be actual numbers or they might be parameters that inform my logic to go grab a piece of data or peform some operation and substitute the result in place of the parameter. The result of the calculation needs to be stored in the database so it can accessed by other applications.

For example: the user enters the following formula in the data entry application into a text box:

{AccountBalance * .25) * ExchangeRate

Account Balance is a parameter that is defined in another table that I need to resolve to a numerical value. That part is easy. If the value of AccountBalance = 1000 and for simplicity sake assume the ExchangeRate is 1.00 the result of the math statement is 250.

The only way I can think to accomplish this is to create a .p on the fly that contains the math statement I parsed together and then run the .p. Am I on the right track or is there a better way? I could have thousands of records to process with this type of logic so performance is a huge concern.

Thanks.