baperl has asked for the wisdom of the Perl Monks concerning the following question:
this inserted NULL into date, so I rewrote it as:my $in_rec="INSERT INTO $table (name,trans_date,price) VALUES(\'$name\ +',\'$dt\',\'$prc\');"; my $sth=$dbh->prepare($in_rec);
but then I get the following error:my $tdt="select str_to_date(\'$dt\','%m/%d/%Y');"; my $in_rec="INSERT INTO $table (name,trans_date,price) VALUES(\'$name\ +',\'$tdt\',\'$prc\');"; my $sth=$dbh->prepare($in_rec);
is there a way I can include the STR_TO_DATE within my INSERT statement itself? can you please help me fix this...thanks!DBD::mysql::st execute failed: You have an error in your SQL syntax; c +heck the manual that corresponds to your MySQL server version for the + right syntax to use near '07/29/2011','%m/%d/%Y');','30.53')' at lin +e 1 at test.pl line 34. SQL error:$DBI::errstr
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: STR_TO_DATE in Perl code
by Anonymous Monk on Jul 31, 2011 at 21:27 UTC | |
by baperl (Sexton) on Aug 01, 2011 at 16:36 UTC |