- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Now I understand why others call you a troll!!
Admin
How about:
create table calc ( c_cost number, c_discount number result always generated as (c_cost-c_discount) virtual) ;
and then
public double calculateCostSQL(double cost,double discount){ ResultSet rs = null; double resp = 0; try{ String quer1 = null; quer1 = "INSERT INTO calc c_cost,c_discount values ("cost","discount")"; dbm.query(quer1); String quer2 = null; quer2 = "select result FROM calc where c_cost= "cost" and c_discount="discount; rs = dbm.query(quer2); if(rs.first()) resp = rs.getDouble("result"); } catch(Exception e){ e.printStackTrace(); } finally{ try{ if(rs != null){ rs.close(); rs = null; } } catch(Exception e){ e.printStackTrace(); } } return resp; }
Well...????
Admin
Actually, there is a valid reason for performing it in this manor. As is a somewhat common occurrence on high performance, virtualized environments like the one this enterprise application was running on, mathematics chips fail on local machines.
By utilizing the mathematics processing system (MPS) functionality on the Enterprise edition of Oracle 9g+, you can be assured that whilst a numerical operation may fail due to a similar mathematics chip failure, it will fail consistently throughout the entire organisation, meaning that it only needs to be repaired and adjusted in one place to fix it company wide. This simply makes sense, from a time saving and code quality point of view.
This is why I always code a fresh operating system for every application I release.
Admin
But the original version also includes the extra feature of database query parsing - removing this code may make the poor dba wonder why his shared pool isn't being trashed anymore
Admin
Methinks boog and frits are friends of Alex's, since they do nothing but post irrelevant and provocative comments which never get deleted.
Admin
Admin
Hi,
No... "double cost" just means it's a large business and therefore everything costs twice as much as it should. The discount is double because the cost is double. For example, if something should cost $10 and you get a ("%10 off") discount of $1, then you actually pay $20 less a "double discount" of $2.
At least that's how the marketing department explained the "double discount" system to me...
Admin
Admin
Admin
Admin
I really hope this is real. It would make me feel better about the code I have to deal with on a daily basis.
Admin
Jealousy makes you ugly in your face, sockpuppet #5.
Admin
Admin
Admin
I believe both of you work at my company.
Admin
I guess sarcasm and real life experiences aren't part of the paradigm here.
Admin
The way I see it, the SELECT should have been moved into a parameterized stored procedure that sets the isolation level to repeatable read and then acquires a table lock on all system tables just to keep the entire DBMS in a deterministic state.
Finally, several tiers of data access and business logic classes, ideally located on separate server instances, should be designed to encapsulate the logic and error handling. The exception should then be changed and written to a corresponding web service that collects all exceptions.
From there, you can build a reporting system to allow the subtraction failures to be tracked.
That's my $0.02.
Admin
Admin
CAPTCHA: dolor
Admin
Nope, DES key lengths are always 56-bit. Triple DES then has two recommended keying options, one which uses a pair of 56-bit keys (for an effective 112-bit key length) and one which uses three ("168-bit").
If you wrote crypto code without that kind of basic knowledge of the standard you have repeated a very common crypto WTF. I hope you're not protecting anything important.
Admin
Lol! I guess /. isn't the only good place for nerd jokes
Admin
My guess is that there was a difference in the way the database and the programming language rounded the result.
Admin
He should have used a parallel query to perform the calculation :-))
Admin
Oh man! Why complicate such simple things?
Admin
But that would not require a call to another machine unless you place the JS engine in a cloud perhaps :D
Admin
The Marshal? Isn't like a title of a movie or series? But it's a good name. Impressive.
Admin
Bingo!
Or weren't we playing bullshit bingo?
Admin
Doesn't Oracle do calculations in BCD?
If the calculation depended on BCD then he may have broken it.
Of course a better fix would be to call a local BCD Library.
Admin
Many years ago, a friend of mine who was learning php WHILE building a website for a company, used to do the same thing to do any kind of arithmetic operations... ahhh
Admin
A problem tailor-made for Mechanical Turk
Admin
Since the Oracle can handle numbers with a precision of 39 digits there is of course a meaning with this... Java double has only something like 15 digits.
Now Oracle has no problems in calculating that "1.0000000000000001 - 1" is 1E-16, whereas Java thinks it is zero... This rewrite might have introduced an interesting bug.