I'm mostly looking for ideas here. The odds of my group purchasing something to solve the problem is incredibly low, but go ahead and suggest any commercial products that would help.
The basic problem stems from the following scenario:
- Users input data into a form, which auto-populates some values based on existing data.
- This data is saved and everything is great.
- A report is generated and it is in sync with the data that was saved.
- The database content which determines the auto-populated values now changes.
- Opening the form, the auto-populated values are modified.
- Without saving, the report values need to be updated as well, but they are not.
Other details:
- Our reporting solution requires that the answers and rule evaluations all come from stored procedures or queries in the Oracle database.
- The form is run in a browser.
- Based on the auto-populated values, some parts of the form/report will be visible or invisible.
The Question: How can I implement a set of rules (stored in the database) in a way that I can easily evaluate them from both javascript and SQL?
A rule may look like any of the following:
- If Question 1 is answered with a "Yes", hide questions 2 - 10.
- If Question 3 is answered with a "No", automatically answer "X" to Question 4.
- If Question 1 is "Yes" and Question 3 is "No" and Question 4 is "Yes", then run method "whatever".
I have many possible solutions running through my mind right now, but most of them involve writing two interpreters (one in javascript and one in sql). While this isn't necessarily horrible, dealing with only one interpreter would be best.
Also, the client needs to update the form while the user is entering values, so popping back to the database every time the user changes an answer is not likely to be a practical solution.
Update / Modification
I'm currently leaning toward implementing rules that can be evaluated directly by the javascript (with a bit of code surrounding the rule), and converted/processed by a store procedure into dynamic sql that can evaluate the rules in Oracle.
Any suggestions for that?