2 # script that rebuild thesaurus from biblio table.
4 # delete FROM `marc_subfield_table` WHERE tag = "606" AND subfieldcode = 9;
6 #use warnings; FIXME - Bug 2505
12 use C4
::AuthoritiesMarc
;
13 use Time
::HiRes
qw(gettimeofday);
16 my ( $fields, $number,$language) = ('',0);
17 my ($version, $verbose, $test_parameter, $field,$delete,$subfields);
21 't' => \
$test_parameter,
27 if ($version or !$fields) {
29 Small script to recreate the COUNTRY list in authorised values from existing countries in the catalogue.
30 This script is useful when you migrate your datas with bulkmarcimport.pl as it populates parameters tables that are not modified by bulkmarcimport.
33 \th : this version/help screen
34 \ts : the field or field list where the lang codes are stored.
35 \td : delete every entry of COUNTRY category before doing work.
36 \tl : the language of the language list (fr or en for instance)
38 The table is populated with iso codes and meaning (in french).
39 If the complete language name is unknown, the code is used instead and you will be warned by the script
42 ./buildCOUNTRY.pl -d -s "('102a')"
56 'an' => 'Antilles Néerlandaises',
69 're' => 'Réunion (ile)',
72 ) if $language eq 'fr';
74 my $dbh = C4
::Context
->dbh;
76 print "deleting country list\n";
77 $dbh->do("delete from authorised_values where category='COUNTRY'");
80 if ($test_parameter) {
81 print "TESTING MODE ONLY\n DOING NOTHING\n===============\n";
83 my $starttime = gettimeofday
;
85 my $sth = $dbh->prepare("SELECT count(*) as tot,subfieldvalue FROM marc_subfield_table WHERE tag + subfieldcode IN $fields group by subfieldvalue");
90 print "=========================\n";
91 my $sth2 = $dbh->prepare("insert into authorised_values (category, authorised_value, lib) values (?,?,?)");
92 while (my ($tot,$langue) = $sth->fetchrow) {
93 $sth2->execute('COUNTRY',$langue,$langue?
$codesiso{$langue}:$langue);
94 print "$langue is unknown is iso list (used $tot times)\n" unless $codesiso{$langue};
96 print "=========================\n";