|
Line 0
Link Here
|
| 0 |
- |
1 |
#!/usr/bin/perl |
|
|
2 |
|
| 3 |
# Loop through all of the biblio records in the biblioitems database table and remove the 998 subfield to prevent indexer bugs. |
| 4 |
# |
| 5 |
# Copyright (C) 2018 Catalyst IT Ltd. |
| 6 |
# |
| 7 |
# This program is free software: you can redistribute it and/or modify |
| 8 |
# it under the terms of the GNU General Public License as published by |
| 9 |
# the Free Software Foundation, either version 3 of the License, or |
| 10 |
# (at your option) any later version. |
| 11 |
# |
| 12 |
# This program is distributed in the hope that it will be useful, |
| 13 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
# GNU General Public License for more details. |
| 16 |
# |
| 17 |
# You should have received a copy of the GNU General Public License |
| 18 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 |
|
| 20 |
=head1 NAME |
| 21 |
|
| 22 |
remove_998_subfield.pl - Remove 998$a subfield of all biblios in the catalog |
| 23 |
|
| 24 |
=head1 SYNOPSIS |
| 25 |
|
| 26 |
B<remove_998_subfield.pl> |
| 27 |
|
| 28 |
=head1 DESCRIPTION |
| 29 |
|
| 30 |
B<csv_to_sql.pl> will loop through all of the biblio records in the biblioitems database table and remove the 998 subfield to prevent indexer bugs. |
| 31 |
|
| 32 |
=back |
| 33 |
|
| 34 |
=head1 AUTHOR |
| 35 |
|
| 36 |
Alex Buckley <alexbuckley@catalyst.net.nz> |
| 37 |
|
| 38 |
=cut |
| 39 |
|
| 40 |
use Data::Dumper; |
| 41 |
|
| 42 |
use autodie; |
| 43 |
use Getopt::Long; |
| 44 |
use Modern::Perl; |
| 45 |
use Pod::Usage; |
| 46 |
use Text::CSV_XS; |
| 47 |
use C4::Context; |
| 48 |
use C4::Biblio; |
| 49 |
|
| 50 |
my $dbh = C4::Context->dbh; |
| 51 |
|
| 52 |
my $sth = $dbh->prepare("SELECT biblionumber FROM biblioitem WHERE ExtractValue(marcxml, '//datafield[\@tag=\"440\"]/subfield[\@code>=\"a\"]') != '';"); |
| 53 |
$sth->execute(); |
| 54 |
my $biblio_records = $sth->fetchall_arrayref({ }); |
| 55 |
|
| 56 |
foreach my $biblio_record ( @$biblio_records ) { |
| 57 |
my $bibnum = $biblio_record->{'biblionumber'}; |
| 58 |
my $record = GetMarcBiblio({biblionumber => $bibnum}); |
| 59 |
my $framework = $record->{'framework'}; |
| 60 |
foreach my $field ($record->field('998')) { |
| 61 |
$record->delete_field($field); |
| 62 |
} |
| 63 |
ModBiblioMarc($record, $bibnum, $framework); |
| 64 |
ModZebra( $biblio_record, "specialUpdate", "biblioserver", $record); |
| 65 |
warn "Updated biblio $biblio_record->{'biblionumber'}"; |
| 66 |
} |
| 67 |
|
| 68 |
1; |
| 69 |
|
| 70 |
|