2 # load records that already have biblionumber set into a koha system
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 If your ISO2709 file already has biblionumbers, you can use this script
32 to import the MARC into your database.
34 \th : this version/help screen
35 \tfile /path/to/file/to/dump : the file to dump
37 \t\$ export KOHA_CONF=/etc/koha.conf
38 \t\$ perl misc/marcimport_to_biblioitems.pl -file /home/jmf/koha.mrc
43 my $starttime = gettimeofday;
45 my $dbh = C4::Context->dbh;
47 my $sth2=$dbh->prepare("update biblioitems set marc=? where biblionumber=?");
48 my $batch = MARC::Batch->new( 'USMARC', $input_marc_file );
49 $batch->warnings_off();
51 my ($tagfield,$biblionumtagsubfield) = &GetMarcFromKohaField("biblio.biblionumber","");
54 while ( my $record = $batch->next() ) {
55 my $biblionumber=$record->field($tagfield)->subfield($biblionumtagsubfield);
57 $sth2->execute($record->as_usmarc,$biblionumber) if $biblionumber;
58 print "$biblionumber \n";
61 $timeneeded = gettimeofday - $starttime ;
62 print "$i records in $timeneeded s\n" ;
65 # IS THIS SUPPOSED TO BE __END__ ?? If not, then what is it? --JBA
69 my $nquery="\ \@attr 1=1007 ".$query;
70 my $oAuth=C4::Context->Zconn("biblioserver");
71 if ($oAuth eq "error"){
72 warn "Error/CONNECTING \n";
73 return("error",undef);
76 my $Anewq= new ZOOM::Query::PQF($nquery);
78 $oAResult= $oAuth->search_pqf($nquery) ;
81 warn " /Cannot search:", $@->code()," /MSG:",$@->message(),"\n";
82 return("error",undef);
86 $nbresults=$oAResult->size();
87 if ($nbresults eq "1" ){
88 my $rec=$oAResult->record(0);
89 my $marcdata=$rec->raw();
90 $authrecord = MARC::File::USMARC::decode($marcdata);
92 return ($authrecord,$nbresults);