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
11 use C4
::AuthoritiesMarc
;
12 use Time
::HiRes
qw(gettimeofday);
15 my ( $fields, $number,$language) = ('',0);
16 my ($version, $verbose, $test_parameter, $field,$delete,$subfields);
20 't' => \
$test_parameter,
26 if ($version or !$fields) {
28 Small script to recreate the COUNTRY list in authorised values from existing countries in the catalogue.
29 This script is useful when you migrate your datas with bulkmarcimport.pl as it populates parameters tables that are not modified by bulkmarcimport.
32 \th : this version/help screen
33 \ts : the field or field list where the lang codes are stored.
34 \td : delete every entry of COUNTRY category before doing work.
35 \tl : the language of the language list (fr or en for instance)
37 The table is populated with iso codes and meaning (in french).
38 If the complete language name is unknown, the code is used instead and you will be warned by the script
41 ./buildCOUNTRY.pl -d -s "('102a')"
55 'an' => 'Antilles Néerlandaises',
68 're' => 'Réunion (ile)',
71 ) if $language eq 'fr';
73 my $dbh = C4
::Context
->dbh;
75 print "deleting country list\n";
76 $dbh->do("delete from authorised_values where category='COUNTRY'");
79 if ($test_parameter) {
80 print "TESTING MODE ONLY\n DOING NOTHING\n===============\n";
82 my $starttime = gettimeofday
;
84 my $sth = $dbh->prepare("SELECT count(*) as tot,subfieldvalue FROM marc_subfield_table WHERE tag + subfieldcode IN $fields group by subfieldvalue");
89 print "=========================\n";
90 my $sth2 = $dbh->prepare("insert into authorised_values (category, authorised_value, lib) values (?,?,?)");
91 while (my ($tot,$langue) = $sth->fetchrow) {
92 $sth2->execute('COUNTRY',$langue,$langue?
$codesiso{$langue}:$langue);
93 print "$langue is unknown is iso list (used $tot times)\n" unless $codesiso{$langue};
95 print "=========================\n";