Hi there I am looking for common mistakes pl/sql programmers make when they program applications which deals with a lot of monetary computations. (Discounts, tax, rates, etc.)
I had been using java and hibernate for monetary computations for as far as I can remember java has a set of rules and best practices like BigDecimal to preserve precision and etc. Right now Im trying to improve my pl/sql skills in dealing with financial modules thats why I want to know this gotchas and avoid them. Also are there any existing mantra or pl/sql best practice for this?
Thanks in advance guys.
Hi there I am looking for common mistakes pl/sql programmers make when they program
Share
Using this example:
You can see that the code inserts, for example, 0.11111 which is implicitly rounded to 0.11
When the code immediately tries to count the values for 0.11111 it fails to find any matches.
Similarly the values for (1/14) and (1/15) both get rounded to 0.07.
This isn’t a problem specific to PL/SQL, and I’ve seen similar issues in Java and PHP code when the value in the ‘client’ is rounded when it makes it into the database. PL/SQL does offer a better solution though, as you can declare a variable of the type of a specific table/column, and this binding is maintained even if the column is changed.
So best practice is, when dealing with an SQL statement, use bind variables that are anchored to the type (including length/scale/precision) of the underlying table.