in reply to I got confuse with INSERT
Here's (kind of) what I would do. Everything I do is explained in more detail in the DBI docs. Definitely read the section on placeholders. Not only does it handle quoting for you, it makes this easier by predefining an array with your column names.
I'm guessing the column names in the 1st DB are the same as the second DB.
## UNTESTED ## Setup the column names - This way when you need to change it, you o +nly change in one place ## The column names will also stay in order my @col_names = qw/reg pat ped adnasec impexp cveped adnaent cr +upimp 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 ( $placehold +ers )"; ## We are going to call this quite a bit so lets prepare it out side o +f the loop my $sth = $mysql_dbh1->prepare( $sql ); while ( my @row = $select1->fetchrow_array() ){ ## Stick the result in the other database $sth->execute(@row); }
grep
One dead unjugged rabbit fish later...
One dead unjugged rabbit fish later...
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: I got confuse with INSERT
by padawan_linuxero (Scribe) on Mar 17, 2008 at 16:16 UTC | |
by grep (Monsignor) on Mar 17, 2008 at 20:41 UTC | |
by padawan_linuxero (Scribe) on Mar 24, 2008 at 18:36 UTC | |
by twotone (Beadle) on Aug 17, 2008 at 00:15 UTC |
In Section
Seekers of Perl Wisdom