Wednesday, April 10, 2013

developers gone wild ... make me grumpy

Actually the best suggestion I had from a competent developer was that I the DBA should physically remove the keyboard from this SQL challenged individual.

This should go into Oracle WTF but that blog is not very active these days.

So here we go ... what do you think about this?

One of my developers has this coded in a single table select they are using thru sql developer:
SKU column is ( inventory part number ... VARCHAR2(20) )

SELECT sku,
         site_id,
         site_and_sku,
         qty_oh,
         qty_demand
    FROM schema_name.table_name
   WHERE     qty_oh > 0
         AND (qty_oh - qty_demand < 5)
         AND qty_demand < qty_oh
         AND sku > 'WLD-'
         AND SKU < 'WLE-'
         AND sku = 'WLD-559-5415'
ORDER BY SKU 


???

I did note to this IT professional that many people like to go against character fields with the LIKE operator and that many people like to use greater than and less than against numeric fields MOSTLY ... 

4 comments:

  1. Love the detail of the "order by sku"!
    Just in case it's not WLD-559-5415...

    ReplyDelete
    Replies
    1. Hey Nuno ... yeah just one of many great things about this SQL statement! When in doubt just keep putting more things into the where clause and AND them together! You should have seen the expression on my face when I saw it ... now we know why pirates say AARRGGHHH!

      Delete
  2. Don't laugh...years ago when I was working as a consultant for a MAJOR international company, there was a panicked email from someone high up in the IT department saying that Oracle had introduced a horrible bug in the latest release so you could no longer rely on output being sorted correctly (that was the introduction of HASH GROUP BY), and as the result an ORDER BY was now mandatory for every (!) single SELECT as a workaround. May just as well be the csse here...

    ReplyDelete
  3. As ugly as the ORDER BY is here ... not the first or 2nd or even 3rd thing that caught my eye ( or maybe started my eyes burning ) ...

    ReplyDelete