foreach my $sub (keys %data) { ($Artist, $Song) = split(/\|/, $sub); $DictIDNums = join(", ", @{$data{$sub}}); $CheckQuery = "Insert into MeterMusicTemp..QCStuff Select dictid,filename,'$Song' from (select dictid,filename,artist,title,song,path,hholdid,updated_by,filesize from FMDATAFILE3 where PPMonth=$PPMonth and ($RuleID) and dictid in (select dictid from dictionary d,artist a,song s where d.artistid=a.artistid and d.songid=s.songid and artist='$Artist' and song = '$Song') and matchlevel<3) as T1 where lower(FileName) not like lower('%$Song%') order by filename "; print "$CheckQuery\n"; my $dbh = DBI->connect( "DBI:ODBC:MusicWatch", "App_User", "au", { RaiseError => 1, AutoCommit => 0 }); eval { $dbh->do("$CheckQuery"); $dbh->commit( ); }; if ($@) { eval { $dbh->rollback( ) }; die "Couldn't roll back transaction" if $@; }