2 # load records that already have biblionumber set into a koha system
3 # Written by TG on 10/04/2006
5 #use warnings; FIXME - Bug 2505
7 # find Koha's Perl modules
8 # test carefully before changing this
10 eval { require "$FindBin::Bin/kohalib.pl" };
19 use MARC::File::USMARC;
22 use Time::HiRes qw(gettimeofday);
26 my $input_marc_file = '';
29 'file:s' => \$input_marc_file,
33 if ($version || ($input_marc_file eq '')) {
35 If your ISO2709 file already has biblionumbers, you can use this script
36 to import the MARC into your database.
38 \th : this version/help screen
39 \tfile /path/to/file/to/dump : the file to dump
41 \t\$ export KOHA_CONF=/etc/koha.conf
42 \t\$ perl misc/marcimport_to_biblioitems.pl -file /home/jmf/koha.mrc
47 my $starttime = gettimeofday;
49 my $dbh = C4::Context->dbh;
51 my $sth2=$dbh->prepare("update biblioitems set marc=? where biblionumber=?");
52 my $fh = IO::File->new($input_marc_file); # don't let MARC::Batch open the file, as it applies the ':utf8' IO layer
53 my $batch = MARC::Batch->new( 'USMARC', $fh );
54 $batch->warnings_off();
56 my ($tagfield,$biblionumtagsubfield) = &GetMarcFromKohaField("biblio.biblionumber","");
59 while ( my $record = $batch->next() ) {
60 my $biblionumber = ($tagfield < 10) ? $record->field($tagfield)->data : $record->subfield($tagfield, $biblionumtagsubfield);
62 $sth2->execute($record->as_usmarc,$biblionumber) if $biblionumber;
63 print "$biblionumber \n";
66 $timeneeded = gettimeofday - $starttime ;
67 print "$i records in $timeneeded s\n" ;
70 # IS THIS SUPPOSED TO BE __END__ ?? If not, then what is it? --JBA
74 my $nquery="\ \@attr 1=1007 ".$query;
75 my $oAuth=C4::Context->Zconn("biblioserver");
76 if ($oAuth eq "error"){
77 warn "Error/CONNECTING \n";
78 return("error",undef);
81 my $Anewq= new ZOOM::Query::PQF($nquery);
83 $oAResult= $oAuth->search_pqf($nquery) ;
86 warn " /Cannot search:", $@->code()," /MSG:",$@->message(),"\n";
87 return("error",undef);
91 $nbresults=$oAResult->size();
92 if ($nbresults eq "1" ){
93 my $rec=$oAResult->record(0);
94 my $marcdata=$rec->raw();
95 $authrecord = MARC::File::USMARC::decode($marcdata);
97 return ($authrecord,$nbresults);