my $dbh = DBI->connect( "DBI:ODBC:mydsn", "user", "password", { RaiseError => 0, AutoCommit => 0 } ); my $sql = "Select * from items where procdate = ?"; my $sth = $dbh->prepare($sql); or die "\n\n Unable to prepare SQL query: $DBI::errstr\n\n"; $sth->execute($g_date) or die "\n\n Unable to execute SQL query: $DBI::errstr\n\n"; my $row; print OUTPUT (join(',', @$row), $/) while ($row = $sth->fetch()); $sth->finish(); $dbh->disconnect();