1

My client wants to save an equation formula in a database (Oracle). In this formula they want to use abbreviations of the variables names (field in a table containing the variables) as a descriptive field to see what the formula uses to calculate the result, but wants to be able to calculate the result of the formula when all the variables have values as well.

This means if they change the formula later, the result has to reflect those changes. They have short and long formulas. e.g.

C=(A+B)/100
D=(E+F)/100
G=(3*C)+(4*D)/7

Do you know any reference to something similar to this? I'm using jsp and Oracle as stated before.

Javier
  • 12,100
  • 5
  • 46
  • 57
csanchez84
  • 21
  • 4
  • Where do you want to solve these equations? In Java or Oracle? If Oracle, then take a look at [this PL/SQL calculator](http://odieweblog.wordpress.com/2013/02/03/plsql-rpn-calculator/). – Jon Heller Mar 14 '13 at 05:30

1 Answers1

0

You are on your own. Oracle will not help you much in parsing equations. For simple things, you can iterate over variables and values using SQL REPLACE function and see if that is good enough for you.

igr
  • 3,409
  • 1
  • 20
  • 25
  • 1
    IMHO this is untrue, Oracle may not always be the best tool for this but it can have calculation on columns and combined with dynamic sql you can achive pretty much of it... – A.B.Cade Mar 14 '13 at 05:39
  • You can, but Oracle is not offering much out of the box in that context. Imagine multiple substitutions/iterations to find exact values like: First: A=B+1. Second: B=C+1. 3rd: C=B+D... etc – igr Mar 14 '13 at 07:32
  • How about `connect by`, `recursive CTE` with the use of regular expressions? and this only within the SQL scope - without using PLSQL... But as I said, I'm not claiming that the DB is the best place for such logic (and Oracle Corp. doesn't pay me to say so either...) – A.B.Cade Mar 14 '13 at 07:43
  • There exists different pieces, yes. At the end, we agree that likely is not the best tool for that. It's not problem with DB, but with used languages (SQL, PL/SQL)... – igr Mar 14 '13 at 10:08