2 # script that correct the marcxml from in biblioitems
3 # Written by TG on 10/04/2006
11 use MARC::File::USMARC;
14 use Time::HiRes qw(gettimeofday);
16 my $input_marc_file = '';
19 'file:s' => \$input_marc_file,
23 if ($version || ($input_marc_file eq '')) {
25 small script to import an iso2709 file into Koha with existing biblionumbers in marc record.
27 \th : this version/help screen
28 \tfile /path/to/file/to/dump : the file to dump
30 \t\$ export KOHA_CONF=/etc/koha.conf
31 \t\$ perl misc/marcimport_to_biblioitems.pl -file /home/jmf/koha.mrc
36 my $starttime = gettimeofday;
38 my $dbh = C4::Context->dbh;
40 my $sth2=$dbh->prepare("update biblioitems set marc=? where biblionumber=?");
41 my $batch = MARC::Batch->new( 'USMARC', $input_marc_file );
42 $batch->warnings_off();
44 my ($tagfield,$biblionumtagsubfield) = &GetMarcFromKohaField("biblio.biblionumber","");
47 while ( my $record = $batch->next() ) {
48 my $biblionumber=$record->field($tagfield)->subfield($biblionumtagsubfield);
50 $sth2->execute($record->as_usmarc,$biblionumber) if $biblionumber;
51 print "$biblionumber \n";
54 $timeneeded = gettimeofday - $starttime ;
55 print "$i records in $timeneeded s\n" ;
58 # IS THIS SUPPOSED TO BE __END__ ?? If not, then what is it? --JBA
62 my $nquery="\ \@attr 1=1007 ".$query;
63 my $oAuth=C4::Context->Zconn("biblioserver");
64 if ($oAuth eq "error"){
65 warn "Error/CONNECTING \n";
66 return("error",undef);
69 my $Anewq= new ZOOM::Query::PQF($nquery);
71 $oAResult= $oAuth->search_pqf($nquery) ;
74 warn " /Cannot search:", $@->code()," /MSG:",$@->message(),"\n";
75 return("error",undef);
79 $nbresults=$oAResult->size();
80 if ($nbresults eq "1" ){
81 my $rec=$oAResult->record(0);
82 my $marcdata=$rec->raw();
83 $authrecord = MARC::File::USMARC::decode($marcdata);
85 return ($authrecord,$nbresults);