use strict;
use DBI;
use Data::Dump qw/dump/;
+use Algorithm::CheckDigits;
$|++;
my $import = {
- borrowers => 1,
- issues => 1,
+ borrowers => 0,
+ issues => 0,
};
my $f = DBI->connect("dbi:SQLite:dbname=knjiznica.sqlite","","", { RaiseError => 1, AutoCommit => 0 }) || die $DBI::errstr;
}; # import->{issues}
+
+my $sth = $k->prepare(qq{ select itemnumber,barcode from items });
+my $sth_update = $k->prepare(qq{ update items set barcode=? where itemnumber=? });
+
+$sth->execute;
+warn "update ", $sth->rows, " barcodes";
+
+my $ean = CheckDigits('ean');
+
+while( my $row = $sth->fetchrow_hashref ) {
+ $sth_update->execute( $ean->complete( sprintf('%012d', $row->{barcode}) ), $row->{itemnumber} );
+}
+
$k->commit;