• I've also found that if a function has over 200 IF statements, that it's time to go back to the drawing board. Many such "hopeless" functions frequently do have a much more effective and easy to code solution. there may also be the case where a stored procedure is more appropriate than a function.

    See when people like you say stuff like this I get really worried! :crying:

    The frunction is part of a record linkage application I'm developing. It joins a dataset on itself say on postcode and surname then individual elements of the duplicate pairs are compared and assigend scores for the name part, address, email etc...

    This particualr function calculates the likelyhood of two records having the same name details. See XML below. This is saying that

    IF Surname the same AND Firstname the same then the score will depend on the cmparison of middlename

    But as you can see there are many combinations of this like

    if Surname the same AND forename sounds the same then middlename outcome gives different score.

    Now repeat this for when the surnames sounds the same and when surnames are approximately the same etc and this is how I ended up with so many IFs

    How else to implement this without IF or CASE ststements?!

    Just realised this is so rude.. me hijacking the thread for my own needs. Sorry!

    <lastnames match="equal">

    <firstnames match="equal">

    <middlenames match="equal">sure</middlenames>

    <middlenames match="both_empty">sure</middlenames>

    <middlenames match="one_empty">sure</middlenames>

    <middlenames match="approx">likely</middlenames>

    <middlenames match="contains">likely</middlenames>

    <middlenames match="unequal">possible</middlenames>

    </firstnames>

    <firstnames match="sounds_equal">

    <middlenames match="equal">sure</middlenames>

    <middlenames match="both_empty">likely</middlenames>

    <middlenames match="one_empty">likely</middlenames>

    <middlenames match="approx">possible</middlenames>

    <middlenames match="contains">possible</middlenames>

    <middlenames match="unequal">zero</middlenames>

    </firstnames>

    ---------------------------------------------------------

    It takes a minimal capacity for rational thought to see that the corporate 'free press' is a structurally irrational and biased, and extremely violent, system of elite propaganda.
    David Edwards - Media lens[/url]

    Society has varying and conflicting interests; what is called objectivity is the disguise of one of these interests - that of neutrality. But neutrality is a fiction in an unneutral world. There are victims, there are executioners, and there are bystanders... and the 'objectivity' of the bystander calls for inaction while other heads fall.
    Howard Zinn