Executing Dynamic Calculations with Embedded SQL
November 10, 2004 Michael Sansoterra
The code for this article is available for download.
Every so often I encounter an application where an advanced user wants the ability to maintain a formula. Further, the formula may change every so often, so that building the formulas into the program is undesirable. This is a difficult situation in the RPG world, since the RPG language has no ability to evaluate a string expression at runtime.
Here’s an example:
Formula='Qty * Price * (1 + Case When Qty > 100 Then .10 Else 0 End)';
Fortunately, SQL can handle this dynamic calculation.
This calculation can be done