$dbh = DBI->connect("DBI:ODBC:$db",$user, $pass, {RaiseError => 1}); my $sql_s="SELECT * FROM main WHERE record_number='$db_number'"; $sth = $dbh->prepare($sql_s); $sth->execute() || die $sth->errstr; while ($pointer = $sth->fetchrow_hashref) { $record_id = $pointer->{'record_id'};$record_id=~s/\s//g; if($record_id){ print "
Record Found: $record_id
"; }else{print "
No Record Found
";} }