I was untangling a query when I came across eight variations of this code where only the literals 'a' to 'e' changed. Two of these were nested within an additional NVL so that the second would execute if the first returned null.
nvl(decode(2, 1, 'a', 2, 'b', 3, 'c', 4, 'd', 5, 'e', ' '), 'na')
8 comments:
Sorry, where is the WTF?
What about using the null in the decode? He/she needed just one function, not two :-)
Anonymous, you need to look more carefully:
decode(2,...
This code takes the constant number 2 and then determines whether it is a 1, 2, 3, 4, 5 or other value. Last time I checked, a 2 was always a 2...
Ooooops, right! :-)
Even if sometimes a 2 isn't a 2, the NVL in this code is pointless. The default value of ' ' at the end of the decode guarantees that the decode will never return a null.
Yes I think the nvl is intended as a distraction from the uselessness of the decode. This variation was particularly cunning.
nvl(
nvl(decode(2, 1, 'f', 2, 'g', 3, 'h', 4, 'i', 5, 'j', ' '), 'na'),
nvl(decode(2, 1, 'k', 2, 'l', 3, 'm', 4, 'n', 5, 'o', ' '), 'na')
)
Hooray! Welcome back ;-)
Damn Sploggers :-(
That looks like it was machine-generated by something else, to me, and then pushed into Oracle...
But then why not just work out the decode in the other language? Mysterious.
Post a Comment