ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/dinfo/dinfo-import2
Revision: 1.3
Committed: Tue Aug 26 23:26:37 2003 UTC (20 years, 8 months ago) by root
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +26 -5 lines
Log Message:
*** empty log message ***

File Contents

# Content
1 #!/usr/bin/perl
2
3 use PApp::SQL;
4
5 local $PApp::SQL::DBH = PApp::SQL::connect_cached "dinfo::", "DBI:mysql:dinfo";
6
7 #die "you should not run this program unless you know exactly what you are doing";
8
9 sql_exec "update ort set data='Ummendorf' where data='ummendorf'";
10 sql_exec "update ort set data='Mettenheim' where data='mettenheim'";
11
12 #for my $col (qw(vorname strasse vorwahl plz ort)) {
13 my $st = sql_exec \my($data, $count), "select data, count(*) as c from $col group by 1 having c > 1 order by 2 desc";
14 while ($st->fetch) {
15 my @id = sql_fetchall "select id from $col where data = ?", $data;
16 my $lowest = shift @id;
17 print "$col,$data,$count: @id => $lowest\n";
18 for (@id) {
19 #sql_exec "update row set $col = ? where $col = ?", $lowest, $_;
20 #sql_exec "delete from $col where id = ?", $_;
21 }
22 }
23 }
24
25 for my $col (qw(
26 name
27 vorname
28 zusatz1
29 zusatz2
30 zusatz3
31 vorwahl
32 strasse
33 haus
34 plz
35 ort
36 branche
37 )) {
38 if (0) {
39 my ($id, $count) = sql_fetch "select $col, count(*) from row group by 1 order by 2 desc limit 1";
40 warn "$col => ($id) * $count\n";
41 next unless $id;
42 next;
43 sql_exec "update $col set id = 0 where id = ?", $id;
44 sql_exec "update row set $col = 0 where $col = ?", $id;
45 }
46 }
47