<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Dear Y'all -&nbsp;<div><br></div><div>Damn it, I sent a broken version. &nbsp;Apologies. &nbsp;The following snippet includes the missing "while" line.</div><div><br></div><div>...</div><div><div>&nbsp; $sth = $dbh-&gt;prepare("SELECT * FROM $table_name") || die $dbh-&gt;errstr;</div><div>&nbsp; $sth-&gt;execute() || print "$sth-&gt;errstr\n\n";</div><div>&nbsp;&nbsp;</div><div>&nbsp; while( $r = $sth-&gt;fetchrow_hashref) {</div><div>&nbsp; &nbsp; my $newrec = $schema-&gt;resultset($table_name)-&gt;create($r);</div><div>&nbsp; &nbsp; $newrec-&gt;in_storage();</div><div>&nbsp; }</div><div>&nbsp; $sth-&gt;finish;</div></div><div>...</div><div><br><div><div>On Sep 23, 2013, at 1:13 PM, William Goedicke &lt;<a href="mailto:billy@brant-interactive.com">billy@brant-interactive.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><meta http-equiv="Content-Type" content="text/html charset=us-ascii"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Dear Y'all -&nbsp;<div><br></div><div>I'm migrating a bunch (100ish) tables from Foxpro 2.6 to MSSQL.</div><div><br></div><div>The following code works almost perfectly.</div><div><br></div><div><div><span style="font-size: 14px;">use VB_Temp::Main;</span></div><div><span style="font-size: 14px;">use DBI;</span></div><div><span style="font-size: 14px;">use Data::Dumper;</span></div><div><span style="font-size: 14px;"><br></span></div><div><span style="font-size: 14px;">my $schema = VB_Temp::Main-&gt;connect('dbi:ODBC:VB_Temp');</span></div><div><span style="font-size: 14px;"><br></span></div><div><span style="font-size: 14px;">my $dbf_dir = 'C:/users/goedicw/documents/voicebase/voicedb/';</span></div><div><span style="font-size: 14px;">my $dbh = DBI-&gt;connect("DBI:XBase:".$dbf_dir) or die $DBI::errstr;</span></div><div><span style="font-size: 14px;"><br></span></div><div><span style="font-size: 14px;">foreach ( keys $schema-&gt;{'class_mappings'}) {</span></div><div><span style="font-size: 14px;">&nbsp; /::([^:]+)$/;</span></div><div><span style="font-size: 14px;">&nbsp; my $table_name = $1;</span></div><div><br></div><div><span style="font-size: 14px;">&nbsp; my $vb_temp_rs = $schema-&gt;resultset($table_name);</span></div><div><br></div><div><span style="font-size: 14px;">&nbsp; $vb_temp_rs-&gt;delete_all;</span></div><div><span style="font-size: 14px;"><br></span></div><div><span style="font-size: 14px;">&nbsp; $sth = $dbh-&gt;prepare("SELECT * FROM $table_name") || die $dbh-&gt;errstr;</span></div><div><span style="font-size: 14px;">&nbsp; $sth-&gt;execute() || print "$sth-&gt;errstr\n\n";</span></div><div><span style="font-size: 14px;"><br></span></div><div><span style="font-size: 14px; ">&nbsp; &nbsp; my $newrec = $schema-&gt;resultset($table_name)-&gt;create($r);</span></div><div><span style="font-size: 14px;">&nbsp; &nbsp; $newrec-&gt;in_storage();</span></div><div><span style="font-size: 14px;">&nbsp; }</span></div><div><span style="font-size: 14px;">&nbsp; $sth-&gt;finish;</span></div><div><span style="font-size: 14px;">}</span></div><div><br></div></div><div>Except it fails on datetime fields. &nbsp;I see that the insert statement is constructed to look like:</div><div><br></div><div>insert into tbl (key, somedate) values(100, 19930312);</div><div><br></div><div>which fails.</div><div><br></div><div>insert into tbl (key, somedate) values(100, '199303123')&nbsp;</div><div><br></div><div>however works fine, but I can't get my script to generate the field value that way.</div><div><br></div><div>All help is, of course, most appreciated.</div><div><br></div><div>&nbsp; &nbsp;- Billy</div><div><br></div></div></blockquote></div><br></div></body></html>