[Dbix-class] custom result source calling a stored procedure

Mitchell Elutovich melutovich at gmail.com
Tue Jun 10 18:38:51 GMT 2014


In the package which has the source I've defined the columns and defined an
inflate_result method which blesses $self to a subclass of the package
based on a type column

Currently I've just been using a complex SQL of a union of multiple
SELECTs.  However, I would like to create a temporary table or two and so I
wanted to put everything into a stored proc.


On Tue, Jun 10, 2014 at 2:07 PM, Peter Rabbitson <rabbit+dbic at rabbit.us>
wrote:

> On Tue, Jun 10, 2014 at 07:18:29AM -0400, Mitchell Elutovich wrote:
> > For a customer result source, I know we can do something such as:
> >
> > $new_source->name( \<<SQL );
> >   ( SELECT u.* FROM user u
> >   INNER JOIN user_friends f ON u.id = f.user_id
> >   WHERE f.friend_user_id = ?
> >   UNION
> >   SELECT u.* FROM user u
> >   INNER JOIN user_friends f ON u.id = f.friend_user_id
> >   WHERE f.user_id = ? )
> >   SQL
> >
> > is there any restrictions on the SQL; is it possible to have the SQL just
> > be a call to a stored procedure?
>
> Is there a reason you want to put the sproc behind a source? Why not
> simply do
>
> my @results = $schema->storage->dbh_do(sub {
>   $_[1]->selectall_arrayref(... sproc here ... )
> } );
>
> Cheers
>
>
> _______________________________________________
> 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/20140610/fde0d03b/attachment.htm>


More information about the DBIx-Class mailing list