That might not have anything to do with your problem, but if you add "use strict;" and clean things up, the real problem might be revealed. BTW, I notice that the "doSQL" sub refers to $usingDB, which not passed to or declared within the sub. This is generally considered poor form. It's better for the sub to be fully self-contained, not referring to any globals outside its own scope. (And anyway, if $usingDB is false, this sub shouldn't have been called in the first place.)
As for database performance, perhaps you can figure out a way to use a consistent sql statement with placeholders, such that a given statement only needs to be prepared once per run connection (I presume there's one connection per run). Something like this:
(updated to fix a misspelled variable name)sub doSQL { my ( $tablename, $fldnames, $fldvals ) = @_; # change call params +: # string, array_ref, array_ref my $sqlstring = "insert into $tablename (", join( ',', @$fldnames +) . ') values (' . join( ',', ('?') x scalar @$fieldnames ) . ')'; my $sth = $dbh->prepare_cached( $sqlstring ); $sth->execute( @$fldvals ); # add error checking as desired... }
You'll probably want to read the section in the DBI manual about the "prepare_cached" function.
In reply to Re: MySQL DBI an Socket::IO dropping inserts somewhere
by graff
in thread MySQL DBI an Socket::IO dropping inserts somewhere
by whiteonline
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |