From 12cf801945ebbed32a760e4a5b987583402f6d6d Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 25 Aug 2016 15:18:12 +0100 Subject: [PATCH] Bug 17196: Update switch_marc21_series_info.pl Not sure if this script is still used, could someone confirm? Test plan: If you know how to test it, please do Signed-off-by: Mason James Signed-off-by: Josef Moravec Signed-off-by: Zeno Tajoli Signed-off-by: Nick Clemens Signed-off-by: Marcel de Rooy Signed-off-by: Kyle M Hall --- .../switch_marc21_series_info.pl | 38 ++++++++++++++++--- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/misc/migration_tools/switch_marc21_series_info.pl b/misc/migration_tools/switch_marc21_series_info.pl index 8f0c7f6d02..a51f8306c1 100755 --- a/misc/migration_tools/switch_marc21_series_info.pl +++ b/misc/migration_tools/switch_marc21_series_info.pl @@ -58,16 +58,44 @@ if ( ! $result || $show_help ) { my $dbh = C4::Context->dbh; -my $count_sth = $dbh->prepare( 'SELECT COUNT(biblionumber) FROM biblio CROSS JOIN biblioitems USING (biblionumber) WHERE ExtractValue(marcxml,\'//datafield[@tag="440"]/subfield[@code="a"]\') OR ExtractValue(marcxml,\'//datafield[@tag="440"]/subfield[@code="v"]\') OR ExtractValue(marcxml,\'//datafield[@tag="440"]/subfield[@code="n"]\') OR ExtractValue(marcxml,\'//datafield[@tag="490"]/subfield[@code="a"]\') OR ExtractValue(marcxml,\'//datafield[@tag="490"]/subfield[@code="v"]\')' ); - -my $bibs_sth = $dbh->prepare( 'SELECT biblionumber FROM biblio CROSS JOIN biblioitems USING (biblionumber) WHERE ExtractValue(marcxml,\'//datafield[@tag="440"]/subfield[@code="a"]\') OR ExtractValue(marcxml,\'//datafield[@tag="440"]/subfield[@code="v"]\') OR ExtractValue(marcxml,\'//datafield[@tag="440"]/subfield[@code="n"]\') OR ExtractValue(marcxml,\'//datafield[@tag="490"]/subfield[@code="a"]\') OR ExtractValue(marcxml,\'//datafield[@tag="490"]/subfield[@code="v"]\')' ); +my $count_sth = $dbh->prepare( + q| + SELECT COUNT(biblionumber) + FROM biblio_metadata + WHERE format='marcxml' + AND marcflavour=? + AND ( + ExtractValue(metadata,'//datafield[@tag="440"]/subfield[@code="a"]') + OR ExtractValue(metadata,'//datafield[@tag="440"]/subfield[@code="v"]') + OR ExtractValue(metadata,'//datafield[@tag="440"]/subfield[@code="n"]') + OR ExtractValue(metadata,'//datafield[@tag="490"]/subfield[@code="a"]') + OR ExtractValue(metadata,'//datafield[@tag="490"]/subfield[@code="v"]') + ) + | +); + +my $bibs_sth = $dbh->prepare( + q| + SELECT biblionumber + FROM biblio_metadata + WHERE format='marcxml' + AND marcflavour=? + AND ( + ExtractValue(metadata,'//datafield[@tag="440"]/subfield[@code="a"]') + OR ExtractValue(metadata,'//datafield[@tag="440"]/subfield[@code="v"]') + OR ExtractValue(metadata,'//datafield[@tag="440"]/subfield[@code="n"]') + OR ExtractValue(metadata,'//datafield[@tag="490"]/subfield[@code="a"]') + OR ExtractValue(metadata,'//datafield[@tag="490"]/subfield[@code="v"]') + ) + | +); unless ( $commit ) { print_usage(); } print "Examining MARC records...\n"; -$count_sth->execute(); +$count_sth->execute( C4::Context->preference('marcflavour') ); my ( $num_records ) = $count_sth->fetchrow; unless ( $commit ) { @@ -105,7 +133,7 @@ my %fields = ( }, ); -$bibs_sth->execute(); +$bibs_sth->execute( C4::Context->preference('marcflavour') ); while ( my ( $biblionumber ) = $bibs_sth->fetchrow ) { my $framework = GetFrameworkCode( $biblionumber ) || ''; my ( @newfields ); -- 2.39.5