You might be able to do something like this (omitting the parts that you already have working):
# 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); }
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.

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.