view counter

Beyond NVL

Thanks to Scott Wesley for this story

If there's one thing I've ever learned while developing in Oracle, there is always more than one way to solve a problem.

view counter

The question is - have you done it in the simplest, most intuitive manner?

That's the bar to set, because it may be you the revisits some code 2, 6, 12 months later...

Recently, I came across some code like this:

WHEN NVL(custom_value, normal_value) = normal_value THEN
END AS alt_value

I had a fair idea what it was trying to resolve, but I wasn't sure and I still had to run some scenarios to be sure.
Basically, this was the 2nd of two fields that showed a normal value and a custom value. The first field was simply
NVL(custom_value, normal_value)

The second field should be:
If there is a custom value, show the normal value, otherwise show nothing.

Read the entire article at its source

view counter