[Dbix-class] Re: complex db function

Oleg Pronin syber.rus at gmail.com
Mon Mar 19 15:49:15 GMT 2007


I think that will be too slow. If you fetch 100000 rows, perl function will
be called 100000 times.
If you leave this work for SQL then C function will be called 100000 times
which is much faster.


2007/3/19, rahed <raherh at gmail.com>:
>
> rahed <raherh at gmail.com> writes:
> > select id,round((julianday(date2) - julianday(date1))*86400) as 'tdiff'
> > from mytable;
>
> I proceeded and created a private SQLite function myfunc.
>
> my $dbh =3D $c->model('MyModelDB')->storage->dbh;
> $dbh->func('myfunc',2,\&subtract,'create_function');
>
> sub subtract {
> my (
>      $difference,
>      $end,
>      $start,
>     );
> ($end,$start) =3D @_;
> $difference =3D ($end-$start)*86400;
> return $difference;
> }
>
> And in the search
>
> select =3D> {round=3D>{myfunc=3D>[{'julianday'=3D>'t_end_diag'},
>                            {'julianday'=3D>'t_start_diag'},
>                           ],
>                  };
>
> This produces the required select. Can I go without a private function?
>
> --
> Radek
>
>
> _______________________________________________
> List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
> Wiki: http://dbix-class.shadowcatsystems.co.uk/
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
> Searchable Archive:
> http://www.mail-archive.com/dbix-class@lists.rawmode.org/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20070319/ba4=
b21a5/attachment.htm


More information about the Dbix-class mailing list