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

Peter Rabbitson rabbit+dbic at rabbit.us
Tue Jun 10 18:07:52 GMT 2014


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




More information about the DBIx-Class mailing list