4 # This script generates and fill the thesaurus table
5 # with the data in bibliothesaurus
16 my ($dbh,$sql_cmd)=@_;
17 my $sti=$dbh->prepare($sql_cmd);
20 print "error : ".$sti->errstr." \n tried to execute : $sql_cmd\n";
25 my $sth=$dbh->prepare("show tables");
28 while (my ($table) = $sth->fetchrow) {
30 # print "table $table\n";
33 print "creating thesaurus...\n";
34 dosql($dbh,"CREATE TABLE bibliothesaurus (code BIGINT not null AUTO_INCREMENT, freelib CHAR (255) not null , stdlib CHAR (255) not null , type CHAR (80) not null , PRIMARY KEY (code), INDEX (freelib),index(stdlib),index(type))");
35 my $sti=$dbh->prepare("select count(*) as tot from bibliosubject");
37 my $total = $sti->fetchrow_hashref;
38 my $sti=$dbh->prepare("select subject from bibliosubject");
41 while (my $line =$sti->fetchrow_hashref) {
44 print "$i / $total->{'tot'}\n";
46 # print "$i $line->{'subject'}\n";
47 my $sti2=$dbh->prepare("select count(*) as t from bibliothesaurus where freelib=".$dbh->quote($line->{'subject'}));
50 print "error : ".$sti2->errstr."\n";
53 my $line2=$sti2->fetchrow_hashref;
54 if ($line2->{'t'} ==0) {
55 dosql($dbh,"insert into bibliothesaurus (freelib,stdlib) values (".$dbh->quote($line->{'subject'}).",".$dbh->quote($line->{'subject'}).")");
57 # print "pas ecriture pour : $line->{'subject'}\n";