Anytime you have a huge list of scalars like that it's a sure sign you should be using an array, hash, or other data structure to your advantage. In this case instead of using the big list of scalars you can just use a flat array for each row combined with DBI's prepared statements to do what you need.# Use the list of field names you pulled from the dbf file... # Make the column list for the query... my $fields = join(",", @fieldnames); # Make a string consisting of ?'s joined by commas to be used as DBI # placeholders in the query, one ? for each column... my $placeholders = join(",", ('?') x scalar @fieldnames); # Build and prepare the query... my $insert_query = <<"__END_OF_SQL__"; INSERT INTO oracle_table ($fields) VALUES ( $placeholders ) __END_OF_SQL__ my $oracle_sth = $dbh->prepare($insert_query); # Loop over the rows from the .dbf and use the prepared statement to # insert them into the oracle DB. while (my $row = $dbf_sth->fetchrow_arrayref) { $oracle_sth->execute(@$row); }
In reply to Re: Syntax for list of scalars to be populated by fetchrow_array() ?
by dirving
in thread Syntax for list of scalars to be populated by fetchrow_array() ?
by icskevin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |