Hello monks!

Code first (code works great, but...):

open(SRCFILE, $infile) or die print "Could not open $infile\n"; while($line=<SRCFILE>) { ##### prepare line data $groupnumber=substr($line,863,9); # extract group number $groupnumber =~ s/^\s+//; # Trim leading spaces $groupnumber =~ s/\s+$//; # Trim trailing spaces ##### execute prepared sql statment with linedata parameter $sth->execute($groupnumber) or die print "Unable to execute: $DBI::err +str\n"; ##### fetch recordset if ( $resultset = $sth->fetchrow_array()) { # # groupnumber is in the database (move to the next line) # } else { # else there was no record in the database matching this query. # we'll place this record into the database now. print localtime() . " $groupnumber being inserted into database\n"; $dbh->do("insert into part_group(part_group) Values ($groupnumber)") or die print "Could not insert $groupnumber into part)group: $DBI::er +rstr\n"; } } close(SRCFILE);
I'm checking to see if data exists in a table. If it doesn't, I'm adding it. My SRCFILE has at least 8000 records in it. Is there a faster/better way to do this? Thanks so much.

In reply to DBI - need for speed by with.a.twist

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.