my $sql = "select distinct FID_CUST from session " . "where DAT_END between ? and ?"; print "sql is $sql\n"; my $sth = $dbh->prepare($sql); $sth->execute( $key, $hash{$key} ) or die "Couldn't execute statement: $DBI::errstr";