[Dbix-class] Re: Insert in MSSQL fails on date time fields

Gerhard Jungwirth gjungwirth at sipwise.com
Tue Sep 24 22:24:43 GMT 2013


Hi,

you can set the quoting character.

https://metacpan.org/module/DBIx::Class::Manual::Cookbook#Setting-quoting-f=
or-the-generated-SQL


On 09/24/2013 12:30 PM, William Goedicke wrote:
> Dear Y'all - =

>
> Damn it, I sent a broken version.  Apologies.  The following snippet incl=
udes the missing "while" line.
>
> ...
>   $sth =3D $dbh->prepare("SELECT * FROM $table_name") || die $dbh->errstr;
>   $sth->execute() || print "$sth->errstr\n\n";
>   =

>   while( $r =3D $sth->fetchrow_hashref) {
>     my $newrec =3D $schema->resultset($table_name)->create($r);
>     $newrec->in_storage();
>   }
>   $sth->finish;
> ...
>
> On Sep 23, 2013, at 1:13 PM, William Goedicke <billy at brant-interactive.co=
m> wrote:
>
>> 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 =3D VB_Temp::Main->connect('dbi:ODBC:VB_Temp');
>>
>> my $dbf_dir =3D 'C:/users/goedicw/documents/voicebase/voicedb/';
>> my $dbh =3D DBI->connect("DBI:XBase:".$dbf_dir) or die $DBI::errstr;
>>
>> foreach ( keys $schema->{'class_mappings'}) {
>>   /::([^:]+)$/;
>>   my $table_name =3D $1;
>>
>>   my $vb_temp_rs =3D $schema->resultset($table_name);
>>
>>   $vb_temp_rs->delete_all;
>>
>>   $sth =3D $dbh->prepare("SELECT * FROM $table_name") || die $dbh->errst=
r;
>>   $sth->execute() || print "$sth->errstr\n\n";
>>
>>     my $newrec =3D $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 valu=
e that way.
>>
>> All help is, of course, most appreciated.
>>
>>    - Billy
>>
>
>
>
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.=
co.uk

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20130925/dfe=
4042f/attachment.htm


More information about the DBIx-Class mailing list