http://www.perlmonks.org?node_id=645158


in reply to DBI::bind_colums throws error when element of binding hash is deleteed

If I understand you correctly, take a look at tblSync. I wrote this to do table synchronization between heterogeneous databases. I have since added functionality to handle tables w/ no unique keys.
I believe that the following code is what you're after.
# Set up you db connections - my statment handler is $rsth. # prepare and execute your query etc... __SNIP___ my $fetch = \&fetch; $counter = 0; my @rmaporder = qw|col1 col2 col3|; my %rdb; for ( @rmaporder ) { $counter++; $rdb{$_} = undef; $rsth->bind_col( $counter, \$rdb{$_} ); } my $rkey = 'col1'; # Fetch the data and hold in these hashes %RemoteDB = $fetch->($rsth, \%rdb, $rkey); sub fetch { my $sth = shift; my $dbhash = shift; my $key = shift; my %DB; while ( $sth->fetchrow_hashref ) { # Ensure that ALL data is properly quoted # using the dbi->quote method $DB{$dbhash->{$key}}{$_} = $rdbh->quote($dbhash->{$_}) for keys %$dbhash } return %DB or errpt ( 'FATAL', 'Unable to return data from fetch', + 'NA', 'NA' ); } __SNIP__
Ted
--
"That which we persist in doing becomes easier, not that the task itself has become easier, but that our ability to perform it has improved."
  --Ralph Waldo Emerson
  • Comment on Re: DBI::bind_colums throws error when element of binding hash is deleteed
  • Download Code