in reply to Re^3: MySQL INSERT in Perl
in thread MySQL INSERT in Perl

it was indeed a scoping problem...I fixed it. it runs and it inserts records into the database, but it gives a new error now:
DBD::mysql::db do failed: Unknown column 'N' in 'field list' at otest. +pl line 52.
I am perplexed...it says do failed, but it did insert the records and it does it all correctly...then why the error? this is my updated code:
my $dbh=DBI->connect($dsn,$user,$pwd); foreach my $hr1 (@calls) { my %h1 = %{$hr1}; next unless defined $h1{'symbol'}; my $ins_rec="INSERT INTO $table (symbol,valuation_dt,expn_dt,strik +e,open,bid,ask,last,volume) VALUES(\'$h1{'symbol'}\',now(),\'$exp\',$ +h1{'strike'},$h1{'open'},$h1{'bid'},$h1{'ask'},$h1{'last'},$h1{'volum +e'});"; print "my ins_rec is $ins_rec\n"; my $sth=$dbh->do($ins_rec); }

Replies are listed 'Best First'.
Re^5: MySQL INSERT in Perl
by afoken (Chancellor) on Aug 04, 2011 at 19:40 UTC

    Stop pasting values into your SQL. Use placeholders. Now!

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)