optimisation + encoding set.
authortoins <toins>
Thu, 12 Jul 2007 15:33:31 +0000 (15:33 +0000)
committertoins <toins>
Thu, 12 Jul 2007 15:33:31 +0000 (15:33 +0000)
FIXME : unimarc hard coded.

misc/bulkupdate.pl

index 958f799..35a290a 100644 (file)
@@ -35,8 +35,8 @@ my ( $no_marcxml, $no_isbn, $help) = (0,0,0);
 GetOptions(
     'noisbn'    => \$no_isbn,
     'noxml'     => \$no_marcxml,
-    'h'       => \$help,
-    'help'    => \$help,
+    'h'         => \$help,
+    'help'      => \$help,
 );
 
 
@@ -102,30 +102,34 @@ if(not $no_marcxml){
     
     while (my $data = $sth->fetchrow_arrayref){
         
-        my $biblioitemnumber = $data->[0];
+       my $biblioitemnumber = $data->[0];
        print "\rremoving '-' on marcxml for biblioitemnumber $biblioitemnumber";
         
         # suppression des tirets de l'isbn dans la notice
         my $marcxml = $data->[1];
         
         eval{
-            my $record = MARC::Record->new_from_xml($marcxml);
+            my $record = MARC::Record->new_from_xml($marcxml,'UTF-8','UNIMARC');
             my @field = $record->field('010');
+            my $flag = 0;
            foreach my $field (@field){
                 my $subfield = $field->subfield('a');
                 if($subfield){
                     my $isbn = $subfield;
                     $isbn =~ s/-//g;
                     $field->update('a' => $isbn);
+                    $flag = 1;
                 }
            }
-           $marcxml = $record->as_xml;
-           # Update
-           my $sth = $dbh->prepare($update_marcxml);
-           $sth->execute($marcxml,$biblioitemnumber);
+            if($flag){
+                $marcxml = $record->as_xml;
+                # Update
+                my $sth = $dbh->prepare($update_marcxml);
+                $sth->execute($marcxml,$biblioitemnumber);
+            }
         };
         if($@){
             print "\n /!\\ pb getting $biblioitemnumber : $@";
         }
     }
-}
\ No newline at end of file
+}