foreach (@fields) {
my $sth = $dbh->prepare( 'INSERT INTO temp_sheet ('
.join(',', keys %$_)
.') VALUES ('.
.join(',', map {'?'} keys %$_)
.')'
);
$sth->execute(values %$_);
}
####
# list your headers
my @heading = qw[description billing_code user_id
project_id bad_proj bad_bill bad_user];
# now prepare a statement *once*
my $sth = $dbh-execute( map { $row{$_} } @heading );
}
####
my @heading;
{
my $sth = $dbh->prepare('SELECT TOP 1 * FROM temp_sheet');
$sth->execute;
@heading = @{ $sth->{NAME_lc} };
}