my $sth = $dbh->prepare("SELECT ..."); my @columns = @{$sth->{NAME}}; my @row; $sth->bind_columns(\@row{0..$#columns}); # Then while ($sth->fetch()) { $ins_h->execute(@columns); }