<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 - <div><br></div><div>Damn it, I sent a broken version. Apologies. The following snippet includes the missing "while" line.</div><div><br></div><div>...</div><div><div> $sth = $dbh->prepare("SELECT * FROM $table_name") || die $dbh->errstr;</div><div> $sth->execute() || print "$sth->errstr\n\n";</div><div> </div><div> while( $r = $sth->fetchrow_hashref) {</div><div> my $newrec = $schema->resultset($table_name)->create($r);</div><div> $newrec->in_storage();</div><div> }</div><div> $sth->finish;</div></div><div>...</div><div><br><div><div>On Sep 23, 2013, at 1:13 PM, William Goedicke <<a href="mailto:billy@brant-interactive.com">billy@brant-interactive.com</a>> 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 - <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->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->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->{'class_mappings'}) {</span></div><div><span style="font-size: 14px;"> /::([^:]+)$/;</span></div><div><span style="font-size: 14px;"> my $table_name = $1;</span></div><div><br></div><div><span style="font-size: 14px;"> my $vb_temp_rs = $schema->resultset($table_name);</span></div><div><br></div><div><span style="font-size: 14px;"> $vb_temp_rs->delete_all;</span></div><div><span style="font-size: 14px;"><br></span></div><div><span style="font-size: 14px;"> $sth = $dbh->prepare("SELECT * FROM $table_name") || die $dbh->errstr;</span></div><div><span style="font-size: 14px;"> $sth->execute() || print "$sth->errstr\n\n";</span></div><div><span style="font-size: 14px;"><br></span></div><div><span style="font-size: 14px; "> my $newrec = $schema->resultset($table_name)->create($r);</span></div><div><span style="font-size: 14px;"> $newrec->in_storage();</span></div><div><span style="font-size: 14px;"> }</span></div><div><span style="font-size: 14px;"> $sth->finish;</span></div><div><span style="font-size: 14px;">}</span></div><div><br></div></div><div>Except it fails on datetime fields. 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') </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> - Billy</div><div><br></div></div></blockquote></div><br></div></body></html>