From e7b6c06c99a8db96344f5d07801ca1430e7033bc Mon Sep 17 00:00:00 2001 From: tgarip1957 Date: Wed, 31 May 2006 15:49:38 +0000 Subject: [PATCH] Reads external marc records with biblionumbers and populates koha tables with the new marc record (only the marc record). Useful after changing encodings etc. --- misc/marcimport_to_biblioitems.pl | 86 +++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 misc/marcimport_to_biblioitems.pl diff --git a/misc/marcimport_to_biblioitems.pl b/misc/marcimport_to_biblioitems.pl new file mode 100644 index 0000000000..9d893c3c72 --- /dev/null +++ b/misc/marcimport_to_biblioitems.pl @@ -0,0 +1,86 @@ +#!/usr/bin/perl +# script that correct the marcxml from in biblioitems +# Written by TG on 10/04/2006 +use strict; + +# Koha modules used + +use C4::Context; +use C4::Biblio; +use MARC::Record; +use MARC::File::USMARC; +use MARC::File::XML; +use MARC::Batch; +use Time::HiRes qw(gettimeofday); +use Getopt::Long; +my $input_marc_file = ''; +my ($version); +GetOptions( + 'file:s' => \$input_marc_file, + 'h' => \$version, +); + +if ($version || ($input_marc_file eq '')) { + print <dbh; + +my $sth2=$dbh->prepare("update biblioitems set marc=? where biblionumber=?"); +my $i=0; + +my $batch = MARC::Batch->new( 'USMARC', $input_marc_file ); +$batch->warnings_off(); +$batch->strict_off(); +my $i=0; +my ($tagfield,$biblionumtagsubfield) = &MARCfind_marc_from_kohafield($dbh,"biblio.biblionumber",""); + +while ( my $record = $batch->next() ) { +my $biblionumber=$record->field($tagfield)->subfield($biblionumtagsubfield); +$i++; +$sth2->execute($record->as_usmarc,$biblionumber) if $biblionumber; +print "$biblionumber \n"; +} + +$timeneeded = gettimeofday - $starttime ; + print "$i records in $timeneeded s\n" ; + +END; +sub search{ +my ($query)=@_; +my $nquery="\ \@attr 1=1007 ".$query; +my $oAuth=C4::Context->Zconn("biblioserver"); +if ($oAuth eq "error"){ +warn "Error/CONNECTING \n"; + return("error",undef); +} +my $oAResult; +my $Anewq= new ZOOM::Query::PQF($nquery); +eval { +$oAResult= $oAuth->search_pqf($nquery) ; +}; +if($@){ +warn " /Cannot search:", $@->code()," /MSG:",$@->message(),"\n"; + return("error",undef); +} +my $authrecord; +my $nbresults="0"; + $nbresults=$oAResult->size(); +if ($nbresults eq "1" ){ +my $rec=$oAResult->record(0); +my $marcdata=$rec->raw(); + $authrecord = MARC::File::USMARC::decode($marcdata); +} +return ($authrecord,$nbresults); +} \ No newline at end of file -- 2.39.5