baperl has asked for the wisdom of the Perl Monks concerning the following question:
so, I wrote a print command to see the output on my screen and that produces the results fine. here's the print and the insert command....I suspect I might not be using the right syntax in my INSERT command....can you please help me fix it/point me in the right direction...thx!DBD::mysql::st execute failed: Query was empty at otest.pl line 56. SQL error:$DBI::errstr
Thank you for your replies. Dave, I did use DBIprint "Symbol: $h1{'symbol'}\tExpn_date: $exp\tStrike: $h1{'strike'}\t +Bid: $h1{'bid'}\tAsk: $h1{'ask'}\tLast: $h1{'last'}\tOpen: $h1{'open' +}\tVolume: $h1{'volume'}\n "; my $ins_rec="INSERT INTO $table (symbol,expn_dt,strike,open,bid,ask,la +st,volume) VALUES(\'$h1{'symbol'}\',\'$exp\',\'$h1{'strike'}\',\'$h1{ +'open'}\',\'$h1{'bid'}\',\'$h1{'ask'}\',\'$h1{'last'}\',\'$h1{'volume +'}\');";
NetWallah,this is the code for the INSERT string being applied to the database.my $dbh=DBI->connect($dsn,$user,$pwd) || die "could not connect to dat +abase:$error\n";
When I print $ins_rec, I get a blank... <code> my ins_rec is DBD::mysql::st execute failed: Query was empty at otest.pl line 57. SQL error:$DBI::errstr <code>my $sth=$dbh->prepare($ins_rec); $sth->execute || die "SQL error:$error\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: MySQL INSERT in Perl
by davido (Cardinal) on Aug 04, 2011 at 04:54 UTC | |
by baperl (Sexton) on Aug 04, 2011 at 14:32 UTC | |
by davido (Cardinal) on Aug 04, 2011 at 16:44 UTC | |
by baperl (Sexton) on Aug 04, 2011 at 18:04 UTC | |
by davido (Cardinal) on Aug 04, 2011 at 18:08 UTC | |
| |
|
Re: MySQL INSERT in Perl
by NetWallah (Canon) on Aug 04, 2011 at 04:55 UTC | |
by chromatic (Archbishop) on Aug 04, 2011 at 05:34 UTC | |
by happy.barney (Friar) on Aug 04, 2011 at 12:13 UTC | |
by baperl (Sexton) on Aug 04, 2011 at 15:00 UTC | |
by happy.barney (Friar) on Aug 05, 2011 at 09:17 UTC | |
by baperl (Sexton) on Aug 05, 2011 at 12:28 UTC | |
by baperl (Sexton) on Aug 04, 2011 at 14:34 UTC | |
|
Re: MySQL INSERT in Perl
by Anonymous Monk on Aug 04, 2011 at 06:25 UTC | |
|
Re: MySQL INSERT in Perl
by NetWallah (Canon) on Aug 04, 2011 at 14:36 UTC | |
by baperl (Sexton) on Aug 04, 2011 at 14:45 UTC | |
by NetWallah (Canon) on Aug 04, 2011 at 17:46 UTC | |
by baperl (Sexton) on Aug 04, 2011 at 17:55 UTC | |
by afoken (Chancellor) on Aug 04, 2011 at 19:40 UTC |