On Wed, 10 Jan 2007, [EMAIL PROTECTED] wrote:

Dear list-members and DBIx::Class developers,

Can any of you enlighten me on the best way --if at all possible in
DBIx::Class-- to "translate" the following SQLquery in a DBIx::Class
structure?

SELECT STD(field1 + field2) FROM table WHERE field1 + field2 > 10

[STD is of course the standard deviation function, which is part of the
MySQL function set]

As you will know, STD(field1) + STD(field2) <> STD(field  + field2),
otherwise it would be too easy to apply the function to each field
separately and then add them in my Perl script.

For the condition "field1 + field2 > 10", I have now coded it in raw SQL,
but I wonder if there isn't a more DBIC-ish way.


Hi CountZero! ;)

I'm fairly sure you can just do this:

->search({ .. }, { select => [ { 'std' => [1, 2]} ] ..

of course, since those are fields, and you don't want them quoted, you have to resort to:

->search({ .. }, { select => [ \'STD(field1 + field2)' ] ..

which is a bit less pretty.. (we need scalarrefs=literal everywhere!

Jess



_______________________________________________
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/[email protected]/

Reply via email to