« mod_throttle | Main | How to write Java code that's guaranteed to piss off your co-workers. »

What not to do with SQL

I'm busy redoing our database classes to not be oracle specific.. ran accross this gem:
"SELECT MAX(NVL(COLUMN_NAME,0)) + 1 NEW_VAR FROM TABLE_NAME"

Which creates a new variable, select a max on a column, sets that value on a new variable and returns that..

Which accomplishes the same as this:

"SELECT MAX(COLUMN_NAME) FROM TABLE_NAME" + add 1

which is not oracle specific and more efficient on top of that..