Jump to content

John H Standlee

Member Since 06 Nov 2011
Offline Last Active Feb 04 2024 09:20 AM
-----

#16180 Perl scripts to convert e-Sword 9 bblx and cmtx modules to mysword

Posted by John H Standlee on 09 March 2013 - 08:50 PM

Thanks for your work Rob! 

 

I ran into a problem that I fixed... well, the best way I knew how.  I've never touched Perl, but I know SQL... anyway, I have some e-Sword bibles that had more than one record for a verse, so I modified the following section and added/modified the noted lines:

 

 

# [JHS] BEGIN: added another prepared statement for updating a verse when multiple verses exist (don't know why)
my $sthw2=$dbhw->prepare('
    UPDATE Bible SET Scripture = Scripture || "<br>" || ? WHERE Book=? AND Chapter=? AND Verse=?;
');
# [JHS] END.

foreach my $ref2 (@$rowref) {
    if ($bk != $ref2->[0]) {
        $bk=$ref2->[0];
        my $nm=exists($bibnum{$bk})?$bibnum{$bk}:"UNK";
        print STDERR "\n$nm";
        $cp=0;
    }
    if ($cp != $ref2->[1]) {
        $cp=$ref2->[1];
        print STDERR " $cp";
    }
    $sthw->execute($ref2->[0],$ref2->[1],$ref2->[2],&unrtf($bk,$cp,$ref2->[2],$ref2->[3]));
    # [JHS] BEGIN: added this if statement to catch bad inserts, hope the error is because of dupe verses
    if ($sthw->err){
        $sthw2->execute(&unrtf($bk,$cp,$ref2->[2],$ref2->[3]),$ref2->[0],$ref2->[1],$ref2->[2]);
    }
    die "Error inserting $ref2->[0]/$ref2->[1]/$ref2->[2]/$ref2->[3]\n" if ($sthw2->err);
    # [JHS] END.
}

 

Maybe you can make it more standardized, I assume that an error is because of the dupe verse deal, and it still displays the error on the initial insert, but it seems to be working.

 

~~ John