2 # This script finds and fixes missing 090 fields in Koha for MARC21
3 # Written by TG on 01/10/2005
4 # Revised by Joshua Ferraro on 03/31/2006
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 my $dbh = C4
::Context
->dbh;
23 my $sth=$dbh->prepare("select m.biblionumber,b.biblioitemnumber from marc_biblio m left join biblioitems b on b.biblionumber=m.biblionumber ");
26 while (my ($biblionumber,$biblioitemnumber)=$sth->fetchrow ){
27 my $record = GetMarcBiblio
($biblionumber);
29 MARCmodbiblionumber
($biblionumber,$biblioitemnumber,$record);
33 sub MARCmodbiblionumber
{
34 my ($biblionumber,$biblioitemnumber,$record)=@_;
36 my ($tagfield,$biblionumtagsubfield) = &GetMarcFromKohaField
("biblio.biblionumber","");
37 my ($tagfield2,$biblioitemtagsubfield) = &GetMarcFromKohaField
("biblio.biblioitemnumber","");
40 my @tags = $record->field($tagfield);
44 my $newrec = MARC
::Field
->new( $tagfield,'','', $biblionumtagsubfield => $biblionumber,$biblioitemtagsubfield=>$biblioitemnumber);
45 $record->append_fields($newrec);
51 &ModBiblioMarc
($record,'',$biblionumber);
52 print "$biblionumber \n";