Make the bib record lookup in marc2sre.pl more specific
authordbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 6 Apr 2011 03:58:36 +0000 (03:58 +0000)
committerdbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 6 Apr 2011 03:58:36 +0000 (03:58 +0000)
Don't strip the identifier down to a bare integer if we are doing
a lookup of the value in the bib record. Otherwise, identifiers
such as ABC1001 and ABC001 will overlap ('%001' will return both
records).

git-svn-id: svn://svn.open-ils.org/ILS/trunk@19993 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/extras/import/marc2sre.pl

index ee3acd9..21df735 100755 (executable)
@@ -89,12 +89,8 @@ while ( try { $rec = $batch->next } otherwise { $rec = -1 } ) {
     }
     my $record = $count;
 
-    # On some systems, the 001 actually points to the record ID
-    # We need to attach to the call number to handle holdings in different libraries
-    # but we can work out call numbers later in SQL by the record ID + call number text
     if ($record_field) {
         $record = $record_field->data;
-        $record =~ s/^.*?(\d+).*?$/$1/o;
     }
 
     # If we have been given bibfield / bibsubfield values, use those to find
@@ -105,6 +101,9 @@ while ( try { $rec = $batch->next } otherwise { $rec = -1 } ) {
             print("Could not find matching bibliographic record for $record\n");
         }
         $record = $result->record;
+    } else {
+        # Strip the identifier down to a usable integer
+        $record =~ s/^.*?(\d+).*?$/$1/o;
     }
 
     (my $xml = $rec->as_xml_record()) =~ s/\n//sog;
@@ -192,7 +191,7 @@ sub map_id_to_bib {
 
     my %search = (
         tag => $bibfield, 
-        value => { like => '%' . $record }
+        value => { ilike => '%' . $record }
     );
 
     if ($bibsubfield) {