2 # script that correct the marcxml from in biblioitems
3 # Written by TG on 10/04/2006
6 # find Koha's Perl modules
7 # test carefully before changing this
9 eval { require "$FindBin::Bin/kohalib.pl" };
17 use MARC::File::USMARC;
20 use Time::HiRes qw(gettimeofday);
22 my $input_marc_file = '';
25 'file:s' => \$input_marc_file,
29 if ($version || ($input_marc_file eq '')) {
31 small script to import an iso2709 file into Koha with existing biblionumbers in marc record.
33 \th : this version/help screen
34 \tfile /path/to/file/to/dump : the file to dump
36 \t\$ export KOHA_CONF=/etc/koha.conf
37 \t\$ perl misc/marcimport_to_biblioitems.pl -file /home/jmf/koha.mrc
42 my $starttime = gettimeofday;
44 my $dbh = C4::Context->dbh;
46 my $sth2=$dbh->prepare("update biblioitems set marc=? where biblionumber=?");
47 my $batch = MARC::Batch->new( 'USMARC', $input_marc_file );
48 $batch->warnings_off();
50 my ($tagfield,$biblionumtagsubfield) = &GetMarcFromKohaField("biblio.biblionumber","");
53 while ( my $record = $batch->next() ) {
54 my $biblionumber=$record->field($tagfield)->subfield($biblionumtagsubfield);
56 $sth2->execute($record->as_usmarc,$biblionumber) if $biblionumber;
57 print "$biblionumber \n";
60 $timeneeded = gettimeofday - $starttime ;
61 print "$i records in $timeneeded s\n" ;
64 # IS THIS SUPPOSED TO BE __END__ ?? If not, then what is it? --JBA
68 my $nquery="\ \@attr 1=1007 ".$query;
69 my $oAuth=C4::Context->Zconn("biblioserver");
70 if ($oAuth eq "error"){
71 warn "Error/CONNECTING \n";
72 return("error",undef);
75 my $Anewq= new ZOOM::Query::PQF($nquery);
77 $oAResult= $oAuth->search_pqf($nquery) ;
80 warn " /Cannot search:", $@->code()," /MSG:",$@->message(),"\n";
81 return("error",undef);
85 $nbresults=$oAResult->size();
86 if ($nbresults eq "1" ){
87 my $rec=$oAResult->record(0);
88 my $marcdata=$rec->raw();
89 $authrecord = MARC::File::USMARC::decode($marcdata);
91 return ($authrecord,$nbresults);