From 00dac95bdf57c394b18604f75160c4c7a4e935e4 Mon Sep 17 00:00:00 2001 From: Paul Poulain Date: Fri, 11 Sep 2009 17:15:55 +0200 Subject: [PATCH] misc/maintenance/sync_items_in_marcbibs enhance Adding a way do select the biblios you want to update Signed-off-by: Henri-Damien LAURENT --- misc/maintenance/sync_items_in_marc_bib.pl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/misc/maintenance/sync_items_in_marc_bib.pl b/misc/maintenance/sync_items_in_marc_bib.pl index 159c48f4ea..af89769a89 100755 --- a/misc/maintenance/sync_items_in_marc_bib.pl +++ b/misc/maintenance/sync_items_in_marc_bib.pl @@ -18,9 +18,11 @@ $| = 1; # command-line parameters my $want_help = 0; my $do_update = 0; +my $wherestrings; my $result = GetOptions( 'run-update' => \$do_update, + 'where=s@' => \$wherestrings, 'h|help' => \$want_help, ); @@ -46,9 +48,12 @@ $dbh->commit(); exit 0; sub process_bibs { - my $sql = "SELECT biblionumber FROM biblio ORDER BY biblionumber ASC"; + my $sql = "SELECT biblionumber FROM biblio JOIN biblioitems USING (biblionumber)"; + $sql.="WHERE ". join(" AND ",@$wherestrings) if ($wherestrings); + $sql.="ORDER BY biblionumber ASC"; my $sth = $dbh->prepare($sql); - $sth->execute(); + eval{$sth->execute();}; + if ($@){ die "error $@";}; while (my ($biblionumber) = $sth->fetchrow_array()) { $num_bibs_processed++; process_bib($biblionumber); @@ -139,6 +144,7 @@ not in sync with the items table. Parameters: --run-update run the synchronization + --where condition selects the biblios on a criterium (Repeatable) --help or -h show this message. _USAGE_ } -- 2.20.1