'$LINK_ID'
####
$dbh->{FetchHashKeyName} = 'NAME_lc';
my $val_loh = $dbh->selectall_arrayref($sql,{Slice => {}});
####
use strict;
use warnings;
use DBI;
my $dbh = DBI->connect($dsn,$username,$password) or die $DBI::errstr;
# Request lowercase column names
$dbh->{FetchHashKeyName} = 'NAME_lc';
my $sql_read = ''; # Whatever SQL you are using to select the records
# Fetch a list of hashes.
# The {Slice => {}} is an option provided to DBI that requests the list of hashes
my $val_loh = $dbh->selectall_arrayref($sql_read,{Slice => {}});
for my $row (@$val_loh) {
print "link_id = $row->{link_id}\n";
my @columns = keys %$row;
my @placeholders = map {'?'} @columns;
my $sql_write = sprintf "INSERT INTO ORACLE_TABLE (%s) VALUES (%s)",
join(',',@columns),
join(',',@placeholders);
print $sql_write,"\n";
# Enable the following line after you confirm this code is correct
# $dbh->do($sql,{},@{$row}{@columns});
}