Handle divide by zero in select in OracleActually, I could do an entire blog entry, or even an conference session on the topic of avoiding the N+1 query problem when displaying data from legacy databases. Only in my case, it’s more like 7N+1. But, let’s just get down to today’s specific case. I needed to display a table of values, and I wanted to be able to sort the table on any of the columns. Sorting is most efficiently done by the database, no? But several of the columns were actually derived data, with simple calculations. You can still sort on such things, IF you create a custom column aka - “SELECT cola/colb as custom_column FROM …”. Unfortunately, if colb contains any zeros, the query will blow up. :-p
There are a couple of solutions, but my fav - nullif to the rescue:
Ruby strftime codes
Found myself needing this in two different projects today, for 2 different kinds of formatting dates and times. So I have to give it the nod
Acl9 and time limited comment editing
The above link is a great example of using acl9 authorization to do something non-trivial. Unfortunately, it’s implemented… wrong. The good part is that the specs provided actually fail. The bad part is the time it takes to figure out the error is actually a logical error in the code, and not some transcription error you made when you tried it out yourself.
The implementation of is_owner? is logically… wrong, but the test is correct.
(P.S. I know I’ve gotten behind on this. Take the “today” mentions with a grain of salt. I am still collecting these snippets every week, and I have quite a back-log to work thru)