in reply to Re^2: Database copy table with DBI
in thread Database copy table with DBI

Why not print and insert in the same loop ?

while( my @results = $table_results->fetchrow_array()){ print join ",",@results; print "\n"; $sth_insert->execute(@results); }
poj

Replies are listed 'Best First'.
Re^4: Database copy table with DBI
by cbtshare (Monk) on Nov 15, 2016 at 03:18 UTC
    thank you, I am however getting an error when using your method it always complains about the join statement

    Use of uninitialized value $results14 in join or string at rdscopy.pl line 92. and I also get

    DBD::mysql::st execute failed: Duplicate entry '10157236320140648_1015 +7237405105648' for key 'PRIMARY' at rdscopy.pl line 94. DBD::mysql::st execute failed: Duplicate entry '10157236320140648_1015 +7237405105648' for key 'PRIMARY' at rdscopy.pl line 94.

    ##print and insert at the same time while( my @results = $table_results->fetchrow_array()) { print join(",",@results); print "\n"; $sth_insert->execute(@results); }

    But I do not get that duplicate error when I use the code below, do you know why? Its the same data

    while (my $insert = $table_results->fetchrow_array()) { $sth_insert->execute(@$insert); }
      > Its the same data

      Unless you use fetchrow_arrayref in the latter code, it's not the same data.

      ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
      I do not get that duplicate error when I use the code below, do you know why?

      Probably because you are not inserting any records having retrieved them all in the first while loop. What are the PrintError and RaiseError settings for the dbh2 handle ?

      poj
        performs basic automatic error reporting with DBI