[Dbix-class] Problem getting data from resultset

Devin Austin devin.austin at gmail.com
Fri Jul 6 14:18:59 GMT 2012


I'm late to the party here but you're using Catalyst, what's wrong with the spreadsheet view?  (forgive me for not linking it)

Sent from my iPhone

On Jul 6, 2012, at 8:09 AM, Kenneth S Mclane <ksmclane at us.ibm.com> wrote:

> 
> > your code will only work for fields in the main table of your resultset,
> > but will break for relations. for example,
> > $data->department.department_code is not a valid accessor. you will have
> > to parse your field definition and convert it into
> > $data->department->department_code in order to retrieve the data.
> > 
> > HTH
> > 
> >     patrick
> > 
> > -- 
> > Patrick Meidl ........................ patrick at pantheon.at
> > Vienna, Austria ...................... http://gplus.to/pmeidl
> 
> Ok, I now have this code: 
> 
> my @fields = qw/ department.department_code account_code account_name account_policy compliance.percent_compliant metrics.num_servers metrics.num_subsystems progress.percent_complete /; 
>         foreach my $field (@fields) { 
>                 $ws->write($row, $col, $field); 
> 
>                 $col++; 
>         } 
>         $col=0; 
>         $row++; 
>         while (my @data =$sr->next) { 
>                 foreach my $data (@data) { 
>                         foreach my $field (@fields) { 
>                                 if ($field =~ /\./) { 
>                                         $field = join( "->", split( /\./, $field)); 
>                                 } 
>                                 $ws->write($row, $col, $data->$field); 
> 
>                                 $col++; 
>                         } 
>                         $col=0; 
>                 }         
>                 $row++; 
>         } 
> Which gives this error: 
> Caught exception in dbms::Controller::AccountView->list "Can't locate object method "department->department_code" via package "dbms::Model::ORANGES::Account" at /opt/catalyst/dbms/script/../lib/dbms/Controller/AccountView.pm line 65." 
> 
> The if replaces the "." with a "->" as you can see. 
> _______________________________________________
> 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/20120706/3fc5ffa5/attachment.htm


More information about the DBIx-Class mailing list