jenalice has asked for the wisdom of the Perl Monks concerning the following question:
I am retrieving a bunch of values out of one database, trying to fix the format and reinsert into a different master database, which would usually be fine, but 3 of my values are giving me a heck of a time. There are three numeric values in the first DB that I would like to format into a date time and insert into the new DB
#Taking the values one at a time, and assigning to variables $DOBYear = $ayDOB_Year[$i]; $DOBMonth = $ayDOB_Month[$i]; $DOBDay = $ayDOB_Day[$i]; #Concatonating the string $ODBCDate = sprintf("%4d-%02d-%02d", $DOBYear, $DOBMonth, $DOBDay);
Up to hear everything is groovy, but when I try to insert this into the new SQL table I am getting the following error:
Error:Ok so then I tried casting it on the insert statement, and it still isn't working!
$sqlInsert = "Insert into tblMaster (List_Name_, Gender_, First_Name_, + Last_Name_, Full_Name_, Address_1_, City_, State_, Zip_Code_, SCF_Co +de_, Country_, Email_, Domain_Name_, TLD_, DOB_) Values ('$ListName', +'$Gender','$FirstName','$LastName','$FullName','$Address','$City','$S +tate','$Postal','$SCF','$Country', '$Email','$DomainName','$TLD', cas +t('$ODBCDate' as datetime))";
When I print the SQL statement out to the window and paste into SQL it works fine!! Anyone have any insight??
janitored by ybiC: <code> tags around example code, <tt> around error message
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: perl dates into string into SQL
by hmerrill (Friar) on Sep 17, 2003 at 20:19 UTC | |
by bean (Monk) on Sep 17, 2003 at 21:31 UTC | |
|
Re: perl dates into string into SQL
by bear0053 (Hermit) on Sep 17, 2003 at 17:30 UTC | |
|
Re: perl dates into string into SQL
by Plankton (Vicar) on Sep 17, 2003 at 17:49 UTC | |
|
Re: perl dates into string into SQL
by jenalice (Initiate) on Sep 17, 2003 at 17:36 UTC | |
by iburrell (Chaplain) on Sep 17, 2003 at 18:18 UTC | |
by bear0053 (Hermit) on Sep 17, 2003 at 17:46 UTC |