Thursday, May 25, 2006

If in doubt, test, test and test again

Thanks to Rob Baillie for the following example...


I was glancing through some legacy code today, and came across this.

It's funny how barnacles can accumulate when code changes over time.

            if r2.status_id = 3 then
                 v_gp := r2.rate;
            elsif r2.status_id in (11, 12) then
                if r2.type_id = 3 then
                    v_gp := r2.rate;
                else
                    v_gp := r2.rate;
                end if;
            else
                v_gp := r2.rate;
            end if;

Skip over the record being called r2 and work out what it actually does...

1 comment:

Noons said...

That v_gp WILL be equal to r2.rate, if it's the last thing I do!!!