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" };
18 use MARC
::File
::USMARC
;
21 use Time
::HiRes
qw(gettimeofday);
25 my $input_marc_file = '';
28 'file:s' => \
$input_marc_file,
32 if ($version || ($input_marc_file eq '')) {
34 If your ISO2709 file already has biblionumbers, you can use this script
35 to import the MARC into your database.
37 \th : this version/help screen
38 \tfile /path/to/file/to/dump : the file to dump
40 \t\$ export KOHA_CONF=/etc/koha.conf
41 \t\$ perl misc/marcimport_to_biblioitems.pl -file /home/jmf/koha.mrc
46 my $starttime = gettimeofday
;
48 my $dbh = C4
::Context
->dbh;
50 my $sth2=$dbh->prepare("update biblioitems set marc=? where biblionumber=?");
51 my $fh = IO
::File
->new($input_marc_file); # don't let MARC::Batch open the file, as it applies the ':utf8' IO layer
52 my $batch = MARC
::Batch
->new( 'USMARC', $fh );
53 $batch->warnings_off();
55 my ($tagfield,$biblionumtagsubfield) = &GetMarcFromKohaField
("biblio.biblionumber","");
58 while ( my $record = $batch->next() ) {
59 my $biblionumber=$record->field($tagfield)->subfield($biblionumtagsubfield);
61 $sth2->execute($record->as_usmarc,$biblionumber) if $biblionumber;
62 print "$biblionumber \n";
65 $timeneeded = gettimeofday
- $starttime ;
66 print "$i records in $timeneeded s\n" ;
69 # IS THIS SUPPOSED TO BE __END__ ?? If not, then what is it? --JBA
73 my $nquery="\ \@attr 1=1007 ".$query;
74 my $oAuth=C4
::Context
->Zconn("biblioserver");
75 if ($oAuth eq "error"){
76 warn "Error/CONNECTING \n";
77 return("error",undef);
80 my $Anewq= new ZOOM
::Query
::PQF
($nquery);
82 $oAResult= $oAuth->search_pqf($nquery) ;
85 warn " /Cannot search:", $@
->code()," /MSG:",$@
->message(),"\n";
86 return("error",undef);
90 $nbresults=$oAResult->size();
91 if ($nbresults eq "1" ){
92 my $rec=$oAResult->record(0);
93 my $marcdata=$rec->raw();
94 $authrecord = MARC
::File
::USMARC
::decode
($marcdata);
96 return ($authrecord,$nbresults);