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
11 use C4::Biblio qw( GetMarcFromKohaField );
12 use MARC::File::USMARC;
15 use Time::HiRes qw( gettimeofday );
16 use Getopt::Long qw( GetOptions );
19 my $input_marc_file = '';
22 'file:s' => \$input_marc_file,
26 if ($version || ($input_marc_file eq '')) {
28 If your ISO2709 file already has biblionumbers, you can use this script
29 to import the MARC into your database.
31 \th : this version/help screen
32 \tfile /path/to/file/to/dump : the file to dump
34 \t\$ export KOHA_CONF=/etc/koha.conf
35 \t\$ perl misc/marcimport_to_biblioitems.pl -file /home/jmf/koha.mrc
40 my $starttime = gettimeofday;
42 my $dbh = C4::Context->dbh;
44 my $sth2=$dbh->prepare("update biblioitems set marc=? where biblionumber=?");
45 my $fh = IO::File->new($input_marc_file); # don't let MARC::Batch open the file, as it applies the ':utf8' IO layer
46 my $batch = MARC::Batch->new( 'USMARC', $fh );
47 $batch->warnings_off();
49 my ($tagfield,$biblionumtagsubfield) = &GetMarcFromKohaField( "biblio.biblionumber" );
52 while ( my $record = $batch->next() ) {
53 my $biblionumber = ($tagfield < 10) ? $record->field($tagfield)->data : $record->subfield($tagfield, $biblionumtagsubfield);
55 $sth2->execute($record->as_usmarc,$biblionumber) if $biblionumber;
56 print "$biblionumber \n";
59 $timeneeded = gettimeofday - $starttime ;
60 print "$i records in $timeneeded s\n" ;
63 # IS THIS SUPPOSED TO BE __END__ ?? If not, then what is it? --JBA
67 my $nquery="\ \@attr 1=1007 ".$query;
68 my $oAuth=C4::Context->Zconn("biblioserver");
69 if ($oAuth eq "error"){
70 warn "Error/CONNECTING \n";
71 return("error",undef);
74 my $Anewq= ZOOM::Query::PQF->new($nquery);
76 $oAResult= $oAuth->search_pqf($nquery) ;
79 warn " /Cannot search:", $@->code()," /MSG:",$@->message(),"\n";
80 return("error",undef);
84 $nbresults=$oAResult->size();
85 if ($nbresults eq "1" ){
86 my $rec=$oAResult->record(0);
87 my $marcdata=$rec->raw();
88 $authrecord = MARC::File::USMARC::decode($marcdata);
90 return ($authrecord,$nbresults);