MySQL Forums
Forum List  »  Perl

INSERT in Perl
Posted by: B A
Date: August 04, 2011 09:40AM

I am trying to run an INSERT command from Perl, and encounter the following error:

DBD::mysql::st execute failed: Query was empty at line 56.
SQL error:$DBI::errstr

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....can you please help me fix the INSERT..thx!

print "Symbol: $h1{'symbol'}\tExpn_date: $exp\tStrike: $h1{'strike'}\tBid: $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,last,volume) VALUES(\'$h1{'symbol'}\',\'$exp\',\'$h1{'strike'}\',\'$h1{'open'}\',\'$h1{'bid'}\',\'$h1{'ask'}\',\'$h1{'last'}\',\'$h1{'volume'}\');";

my $sth=dbh->prepare($ins_rec);


also, if I use my strict;
it doesn't recognize $ins_rec, so I removed use strict; to run the code....

Options: ReplyQuote

Written By
INSERT in Perl
August 04, 2011 09:40AM
August 04, 2011 01:14PM
August 04, 2011 03:20PM
September 08, 2011 01:47PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.