#!/usr/bin/perl #* #* GnuDialer - Complete, free predictive dialer #* #* Complete, free predictive dialer for contact centers. #* #* Copyright (C) 2006, GnuDialer Project #* #* Richard Lyman #* #* This program is free software, distributed under the terms of #* the GNU General Public License. #* use DBI; $drh = DBI->install_driver('mysql') or die("Unable to install driver"); $dbh = DBI->connect("DBI:mysql:dialer",'dialer','1234') or die("Unable to connect"); $queue = "some_campaign_name"; &fix_dupes; $dbh->disconnect; ###################################################################################### sub fix_dupes { $mystring = "UPDATE " . $queue . " SET phone = substring( phone, 2, 10 ) WHERE left( phone, 1 ) = '1' AND length( phone ) =11"; $sth = $dbh->prepare("$mystring"); $sth->execute or die("Unable to excute query"); $mystring = "SELECT id,phone,count(1) FROM " . $queue . " GROUP BY phone HAVING count(1) > 1"; $sth = $dbh->prepare("$mystring"); $sth->execute or die("Unable to excute query"); $i=1; while(@record = $sth->fetchrow_array) { $mywritestring = "update " . $queue . " set disposition = '-8' WHERE id='" . $record[0] . "'"; $sth1 = $dbh->prepare("$mywritestring"); $sth1->execute or die("Unable to excute query"); $i++; } } #*************************