From d808b1882aad93aef19a3075247d24db6eba6fde Mon Sep 17 00:00:00 2001 From: kados Date: Fri, 31 Mar 2006 17:51:18 +0000 Subject: [PATCH] Script written by Tumer Garip that fixes missing 090 fields in a MARC21 Koha database. --- misc/missing090field.pl | 50 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100755 misc/missing090field.pl diff --git a/misc/missing090field.pl b/misc/missing090field.pl new file mode 100755 index 0000000000..d6e4b04018 --- /dev/null +++ b/misc/missing090field.pl @@ -0,0 +1,50 @@ +#!/usr/bin/perl +# This script finds and fixes missing 090 fields in Koha for MARC21 +# Written by TG on 01/10/2005 +# Revised by Joshua Ferraro on 03/31/2006 +use strict; + +# Koha modules used + +use C4::Context; +use C4::Biblio; +use MARC::Record; +use MARC::File::USMARC; + + +my $dbh = C4::Context->dbh; + +my $sth=$dbh->prepare("select m.biblionumber,b.biblioitemnumber from marc_biblio m left join biblioitems b on b.biblionumber=m.biblionumber "); + $sth->execute(); + +while (my ($biblionumber,$biblioitemnumber)=$sth->fetchrow ){ + my $record = MARCgetbiblio($dbh,$biblionumber); + + MARCmodbiblionumber($biblionumber,$biblioitemnumber,$record); + +} + +sub MARCmodbiblionumber{ +my ($biblionumber,$biblioitemnumber,$record)=@_; + +my ($tagfield,$biblionumtagsubfield) = &MARCfind_marc_from_kohafield($dbh,"biblio.biblionumber",""); +my ($tagfield2,$biblioitemtagsubfield) = &MARCfind_marc_from_kohafield($dbh,"biblio.biblioitemnumber",""); + +my $update=0; + my @tags = $record->field($tagfield); + +if (!@tags){ + +my $newrec = MARC::Field->new( $tagfield,'','', $biblionumtagsubfield => $biblionumber,$biblioitemtagsubfield=>$biblioitemnumber); + $record->append_fields($newrec); + $update=1; + } + + +if ($update){ +&MARCmodbiblio($dbh,$biblionumber,$record,'',0); + print "$biblionumber \n"; + } + +} +END; -- 2.39.5