[Dbix-class] retrieve_from_sql

Krzysztof Krzyzaniak eloy at kofeina.net
Thu Aug 4 21:37:04 CEST 2005


Emanuele Zeppieri wrote:
> 
>>-----Original Message-----
>>From: dbix-class-bounces at lists.rawmode.org 
>>[mailto:dbix-class-bounces at lists.rawmode.org] On Behalf Of 
>>Krzysztof Krzyzaniak
>>Sent: Thursday, August 04, 2005 1:28 PM
>>To: dbix-class at lists.rawmode.org
>>Subject: Re: [Dbix-class] retrieve_from_sql
>>
>>
>>Matt S Trout wrote:
>>
>>[..]
>>
>>>>Seriously, I can do even more: if you prefer a more formal 
>>
>>approach, I
>>
>>>>can supply also some quite complete SQL grammar definition 
>>
>>files, that
>>
>>>>can provide a good reference to check if some SQL construct is not
>>>>handled.
>>>
>>>
>>>In that direction you might be better off looking at Darren Duncan's
>>>Rosetta + SQL::Routine code; he's already gone the formal 
>>
>>grammar approach
>>
>>>so we're likely to use that for an implementation at some stage.
>>>
>>
>>Fix me if am I wrong. I wonder if any of abstract sql modules support 
>>functions (builded or defined by user) - I mean something 
>>like "SELECT 
>>function1(field), function2(field) WHERE function3(field) = NULL;
> 
>  
> 
> Syntactically-wise, SQL::Abstract can handle such cases, since it does
> not perform any syntactic check on the field names, so (once fixed the
> missing FROM clause) your query becomes:
> 
> my @fields = ( 'function1(field)', 'function2(field)' );
> my %where = (
> 	'function3(field)' => 'NULL',
> );
> my($stmt, @bind) = $sql->select('t', \@fields, \%where);
> print "$stmt\n"; # if you wanna see it
> 
> (assuming that your NULL comparison is permitted by the DBMS).

O, this is nice. Second example: what with selects without tables at 
all? For example:

select my_table_insert(field1, field2); (which means actually "insert 
into my_table values (field1, field2); select currval("my_table_seq");")

Why I am asking? I am in the beginnig of quite complicated project which 
uses postgresql and pl_perl. And I am thinking what I could gain by 
using some DBI Class module (in Catalyst env).

   eloy
-- 
-------e-l-o-y-----------e-l-o-y- at -t-r-a-n-s-i-l-v-a-n-i-a-.-e-u-.-o-r-g------

        jak to dobrze, że są oceany - bez nich byłoby jeszcze smutniej



More information about the Dbix-class mailing list