in reply to MySQL INSERT in Perl

I don't see anything wrong - just stuff I'd write differently - probably something like:
my $ins_rec="INSERT INTO $table (symbol,expn_dt,strike,open,bid,ask,la +st,volume) VALUES('" . join( "','", map {$h1{$_}} qw| symbol strike open bid ask last +volume |). "')";
You have not showed HOW this insert string is applied into the database.

That is where I suspect the problem is. Please show more of the relevant part of the code.

            "XML is like violence: if it doesn't solve your problem, use more."

Replies are listed 'Best First'.
Re^2: MySQL INSERT in Perl
by chromatic (Archbishop) on Aug 04, 2011 at 05:34 UTC

    Be careful! Not only is your data susceptible to broken SQL statements, it's highly vulnerable to SQL injection attacks. At least run your data through quote (but use placeholders instead).

Re^2: MySQL INSERT in Perl
by happy.barney (Friar) on Aug 04, 2011 at 12:13 UTC
    use SQL::Abstract; my $SQL = SQL::Abstract->new; ... my ($sql, @bind) = $SQL->insert ($table, \%h1); $dbh->do ($sql, {}, @bind);
      thx superdoc, I'm not sure I fully understand how that will work... also, it seems like I should replace prepare/execute with do()?

        SQL::Abstract generates (simple) sql statement from perl data structures.

        Yes, you can replace prepare/execute everywhere you don't care about returned rows or rows are not returned, like insert/update/delete without returning clause. See DBI#do

Re^2: MySQL INSERT in Perl
by baperl (Sexton) on Aug 04, 2011 at 14:34 UTC
    hi NetWallah, I've updated the post with the execute commands et al