From 3f4641bf30490a2bb8ed28c518a65e6882e6d326 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Sat, 6 Jun 2009 18:13:22 -0500 Subject: [PATCH] bug 3201: missing090field.pl - skip bad bibs Patch courtesy of G. Henry Signed-off-by: Galen Charlton --- .../22_to_30/missing090field.pl | 54 ++++++++++--------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/misc/migration_tools/22_to_30/missing090field.pl b/misc/migration_tools/22_to_30/missing090field.pl index 218ce8b5fe..648788ba18 100755 --- a/misc/migration_tools/22_to_30/missing090field.pl +++ b/misc/migration_tools/22_to_30/missing090field.pl @@ -26,7 +26,7 @@ $sth->execute(); my $i=1; while (my ($biblionumber,$biblioitemnumber)=$sth->fetchrow ){ my $record = GetMarcBiblio($biblionumber); - print "."; + print "."; print "\r$i" unless $i %100; MARCmodbiblionumber($biblionumber,$biblioitemnumber,$record); } @@ -38,36 +38,40 @@ sub MARCmodbiblionumber{ my ($tagfield2,$biblioitemtagsubfield) = &GetMarcFromKohaField("biblio.biblioitemnumber",""); my $update=0; - my $tag = $record->field($tagfield); -# warn "ICI : ".$record->as_formatted if $record->subfield('090','a') eq '11546'; + if (defined $record) { + my $tag = $record->field($tagfield); + #warn "ICI : ".$record->as_formatted if $record->subfield('090','a') eq '11546'; -# check that we have biblionumber at the right place, otherwise, update or create the field. - if ($tagfield <10) { - unless ($tag && $tag->data() == $biblionumber) { - if ($tag) { - $tag->update($biblionumber); - } else { - my $newrec = MARC::Field->new( $tagfield, $biblionumber); - $record->insert_fields_ordered($newrec); + # check that we have biblionumber at the right place, otherwise, update or create the field. + if ($tagfield <10) { + unless ($tag && $tag->data() == $biblionumber) { + if ($tag) { + $tag->update($biblionumber); + } else { + my $newrec = MARC::Field->new( $tagfield, $biblionumber); + $record->insert_fields_ordered($newrec); + } + $update=1; } - $update=1; - } - } else { - unless ($tag && $tag->subfield($biblionumtagsubfield) == $biblionumber) { - if($tag) { - $tag->update($tagfield => $biblionumber); - } else { - my $newrec = MARC::Field->new( $tagfield,'','', $biblionumtagsubfield => $biblionumber,$biblioitemtagsubfield=>$biblioitemnumber); - $record->insert_fields_ordered($newrec); + } else { + unless ($tag && $tag->subfield($biblionumtagsubfield) == $biblionumber) { + if($tag) { + $tag->update($tagfield => $biblionumber); + } else { + my $newrec = MARC::Field->new( $tagfield,'','', $biblionumtagsubfield => $biblionumber,$biblioitemtagsubfield=>$biblioitemnumber); + $record->insert_fields_ordered($newrec); + } + $update=1; } - $update=1; } + } else { + warn "problem with :".$biblionumber." , record undefined"; } - - - if ($update){ + + + if ($update){ &ModBiblioMarc($record,$biblionumber,''); - print "\n modified : $biblionumber \n"; + print "\n modified : $biblionumber \n"; } } -- 2.39.5