From e7209ed02a3fa9111389e2a1348754f75e70c391 Mon Sep 17 00:00:00 2001 From: Paul POULAIN Date: Thu, 17 Apr 2008 19:53:01 +0200 Subject: [PATCH] UNIMARC specific rebuild items correctly note 995 for items is hardcoded, so it's really for UNIMARC only. The script exit if you're not UNIMARCflavour Signed-off-by: Joshua Ferraro --- misc/migration_tools/upgradeitems.pl | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 misc/migration_tools/upgradeitems.pl diff --git a/misc/migration_tools/upgradeitems.pl b/misc/migration_tools/upgradeitems.pl new file mode 100755 index 0000000000..d2cd6a7292 --- /dev/null +++ b/misc/migration_tools/upgradeitems.pl @@ -0,0 +1,30 @@ +#!/usr/bin/perl + +use strict; +use C4::Context; +use C4::Items; +use C4::Biblio; + +my $dbh=C4::Context->dbh; + +if (C4::Context->preference("marcflavour") ne "UNIMARC" { + print "this script is for UNIMARC only\n"; + exit; +} +my $rqbiblios=$dbh->prepare("SELECT biblionumber from biblioitems"); +$rqbiblios->execute; +$|=1; +while (my ($biblionumber)= $rqbiblios->fetchrow_array){ + my $record=GetMarcBiblio($biblionumber); + foreach my $itemfield ($record->field('995')){ + my $marcitem=MARC::Record->new(); + $marcitem->encoding('UTF-8'); + $marcitem->append_fields($itemfield); + eval{ModItemFromMarc($marcitem,$biblionumber,$itemfield->subfield('9'));}; + print "\r$biblionumber"; + if ($@){ + warn "$biblionumber : $@"; + warn $record->as_formatted; + } + } +} \ No newline at end of file -- 2.39.5