5 # find Koha's Perl modules
6 # test carefully before changing this
8 eval { require "$FindBin::Bin/kohalib.pl" };
17 # command-line parameters
22 my $result = GetOptions(
23 'verbose' => \$verbose,
24 'test' => \$test_only,
25 'h|help' => \$want_help
28 if (not $result or $want_help) {
33 my $num_bibs_processed = 0;
34 my $num_bibs_modified = 0;
35 my $dbh = C4::Context->dbh;
36 $dbh->{AutoCommit} = 0;
43 my $sql = "SELECT biblionumber FROM biblio ORDER BY biblionumber ASC";
44 my $sth = $dbh->prepare($sql);
46 while (my ($biblionumber) = $sth->fetchrow_array()) {
47 $num_bibs_processed++;
48 process_bib($biblionumber);
50 if (not $test_only and ($num_bibs_processed % 100) == 0) {
51 print_progress_and_commit($num_bibs_processed);
61 Bib authority heading linking report
62 ------------------------------------
63 Number of bibs checked: $num_bibs_processed
64 Number of bibs modified: $num_bibs_modified
69 my $biblionumber = shift;
71 my $bib = GetMarcBiblio($biblionumber);
72 my $headings_changed = LinkBibHeadingsToAuthorities($bib);
74 if ($headings_changed) {
76 my $title = substr($bib->title, 0, 20);
77 print "Bib $biblionumber ($title): $headings_changed headings changed\n";
80 ModBiblio($bib, $biblionumber, GetFrameworkCode($biblionumber));
86 sub print_progress_and_commit {
89 print "... processed $recs records\n";
94 $0: link headings in bib records to authorities.
96 This batch job checks each bib record in the Koha
97 database and attempts to link each of its headings
98 to the matching authority record.
101 --verbose print the number of headings changed
103 --test only test the authority linking
104 and report the results; do not
105 change the bib records.
106 --comment <comment> optional comment to describe
107 the record batch; if the comment
108 has spaces in it, surround the
109 comment with quotation marks.
110 --help or -h show this message.