From a51118833c5c78c32abfca9766289a309fb3cdc8 Mon Sep 17 00:00:00 2001 From: Mason James Date: Sun, 11 Nov 2007 17:58:33 -0600 Subject: [PATCH] wrapping AddBiblio(), and AddItem() in evals{} to protect import from failure due to bad records. Signed-off-by: Chris Cormack Signed-off-by: Joshua Ferraro --- misc/migration_tools/bulkmarcimport.pl | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/misc/migration_tools/bulkmarcimport.pl b/misc/migration_tools/bulkmarcimport.pl index b13dde8158..cc186cb4fd 100755 --- a/misc/migration_tools/bulkmarcimport.pl +++ b/misc/migration_tools/bulkmarcimport.pl @@ -294,15 +294,25 @@ while ( my $record = $batch->next() ) { } print "$i : $nbitems items found\n" if $verbose; # now, create biblio and items with Addbiblio call. + unless ($test_parameter) { - my ($bibid,$oldbibitemnum) = AddBiblio($newRecord,''); - warn "ADDED biblio NB $bibid in DB\n" if $verbose; - for (my $i=0;$i<=$#items;$i++) { -# warn "here is the biblioitemnumber $oldbibitemnum"; - AddItem($items[$i],$bibid,$oldbibitemnum); - } - } + my ( $bibid, $oldbibitemnum ); + eval { ( $bibid, $oldbibitemnum ) = AddBiblio( $newRecord, '' ); }; + warn $@ if $@; + if ( $@ ) { + warn "ERROR: Adding biblio $bibid failed\n" if $verbose + } else { + warn "ADDED biblio NB $bibid in DB\n" if $verbose; + for ( my $it = 0 ; $it <= $#items ; $it++ ) { + eval { AddItem( $items[$it], $bibid, $oldbibitemnum ); }; + warn "ERROR: Adding item $it, rec $i failed\n" if ($@); + } + } + } + last if $i == $number; } + + if ($fk_off) { $dbh->do("SET FOREIGN_KEY_CHECKS = 1"); } -- 2.39.5