When attempting to duplicate a typical spreadsheet-based app, data generally falls into 2 categories: user-input and formula (vlookup, cells A1+B1=C1, etc) generated. In a report/list view, there are a few options to show the calculated columns like a) 11g virtual columns or b) views containing the formulas as SQL expression.
On a form page, if I want to show the calculated fields as Display Only page items that are dynamically updated with the corresponding input fields, one would use APEX dynamic actions (Change, Set Value, etc).
However, this would mean that the code for the "formulas" is duplicated in the view/table definition and the APEX DA leading to maintenance issues when some formula needs to change.
Is there a way to not duplicate the formula code/expression and make them available to both the DA and the report?
Would you not put your formula in a package function, then when querying data using a view - the function is used; and when displaying calcs on the fly using DA, the function is used via a pl/sql action?
Most of the "formulas" are trivial (string concatenation or simple arithmetic) so the function would be a simple return statement most of the time but you are right, that is indeed a valid approach. Thanks for the idea.
Simple or not simple, I've found if things are repeated - it's worth putting in a package.
I've been burned with re-work in a recent project for not parameterising/encapsulating the simplest of things.