I've moved...

This blog now has a new home - please update your shortcuts and readers to: www.jeffkemponoracle.com. Sorry for any inconvenience!

Friday, May 05, 2006

Fun with copy-and-paste code

Came across this in a form (6i) to be run on a 9i db. Not only is this code about 33 lines of code too long and issues any number of unnecessary database queries, its name is quite unrelated to its intended function.

[Full Article]


  1. Should have replaced it with a TRANSLATE :)
    Seriously, my guess is that sometime l_search_string was a lot longer (hence the loop) and the aim of the procedure was to check whether the input string contained any of the characters in l_search_string (which probably had alphabetic characters, given the procedure's name).
    The simplest way to do that is
    IF ref_in != TRANSLATE(ref_in,
    chr(7)||l_search_string, chr(7)) THEN
    RETURN 'Y'
    RETURN 'N';
    END IF;
    I'm amazed at the way some people will make the smallest possible change to code and never think about whether they can tidy up a whole chunk.

  2. Yeah, I once had a developer rewrite LTRIM and RTRIM in PL/SQL. I ddidn't understand how a (supposedly) experienced developer could believe that as powerful al language as PL/SQL would not have these basic functions as built ins.

    Also interesting is Steven Feuerstein's comments on
    work he did around a home-grown IS_NUMBER function

  3. Thanks for the link James, hadn't come across that one.


Note: only a member of this blog may post a comment.