in reply to Syntax for list of scalars to be populated by fetchrow_array() ?
Unless you are absolutely certain that no values containing single quotes appear in the source data. Instead you should use the quote() method provided by DBI, or use placeholders.'$LINK_ID'
I'm not sure if this will solve your problem, but if you would like to simplify the list of values being provided you could do something like this:
This will provide you with a list of hashrefs, with the keys of the hash being the lowercase version of the columns that were returned. In your example it could work like this:$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 lis +t 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}); }
|
|---|