[Dbix-class] Insert in MSSQL fails on date time fields
William Goedicke
billy at brant-interactive.com
Mon Sep 23 17:13:02 GMT 2013
Dear Y'all -
I'm migrating a bunch (100ish) tables from Foxpro 2.6 to MSSQL.
The following code works almost perfectly.
use VB_Temp::Main;
use DBI;
use Data::Dumper;
my $schema = VB_Temp::Main->connect('dbi:ODBC:VB_Temp');
my $dbf_dir = 'C:/users/goedicw/documents/voicebase/voicedb/';
my $dbh = DBI->connect("DBI:XBase:".$dbf_dir) or die $DBI::errstr;
foreach ( keys $schema->{'class_mappings'}) {
/::([^:]+)$/;
my $table_name = $1;
my $vb_temp_rs = $schema->resultset($table_name);
$vb_temp_rs->delete_all;
$sth = $dbh->prepare("SELECT * FROM $table_name") || die $dbh->errstr;
$sth->execute() || print "$sth->errstr\n\n";
my $newrec = $schema->resultset($table_name)->create($r);
$newrec->in_storage();
}
$sth->finish;
}
Except it fails on datetime fields. I see that the insert statement is constructed to look like:
insert into tbl (key, somedate) values(100, 19930312);
which fails.
insert into tbl (key, somedate) values(100, '199303123')
however works fine, but I can't get my script to generate the field value that way.
All help is, of course, most appreciated.
- Billy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20130923/048133b4/attachment.htm
More information about the DBIx-Class
mailing list