http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=10454

--- Comment #3 from M. Tompsett <[email protected]> ---
Based on an idea from gmcharlt.

Here's Pseudo-code of something I have in mind for fixup_cardnumber. I'm
writing this so I don't forget it when I switch computers later to actually
attempt implementing it.

Already done elsewhere:
CREATE TABLE cardnumber (UID autoincrement,PID string,Value string)

my_cardnumber = select max(cardnumber) from borrowers
check = select cardnumber from borrowers where cardnumber=my_cardnumber;
while the check for the cardnumber exists {

    INSERT into cardnumber (PID) values (randomly generated PID string)
    my_uid = SELECT max(UID) from cardnumber where PID= the randomly generated
PID string

    earliest uid = select min(uid) from cardnumber where value='';
    while there is an earliest uid {
       previous_value = select value from cardnumber where uid=earliest uid-1;
       # the assumption is that f(previous value) will always return the
       # same new value regardless of how many times or when it is called.
       new value = f(previous value);
       update cardnumber set value=new value where uid=earliest uid;
       earliest uid = select min(uid) from cardnumber where value='';
    }

    my_cardnumber = select Value from cardnumber where uid=my_uid
    check = select cardnumber from borrowers where cardnumber=my_cardnumber;
}
return my_cardnumber;

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list
[email protected]
http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to