## UNTESTED ## Setup the column names - This way when you need to change it, you only change in one place ## The column names will also stay in order my @col_names = qw/reg pat ped adnasec impexp cveped adnaent crupimp rfcimp curpaa/; my $col_names_string = join(',',@col_names); my $dbhX1 = DBI->connect('dbi:XBase(RaiseError=1):'); my $select1 = $dbhX1->prepare("SELECT $col_names_string FROM r501"); $select1->execute(); ## Now we create the string with placholders. my $placeholders = join(',',map { '?' } @col_names ); my $sql = "INSERT INTO r501 ( $col_names_string ) VALUES ( $placeholders )"; ## We are going to call this quite a bit so lets prepare it out side of the loop my $sth = $mysql_dbh1->prepare( $sql ); while ( my @row = $select1->fetchrow_array() ){ ## Stick the result in the other database $sth->execute(@row); }