in reply to Re^2: [DbIx::Class] How to execute stored procedure?
in thread [DbIx::Class] How to execute stored procedure?

Hey! People! I've found the design of problem! It was totally unreachable for me till this night! Founded in Cookbook! Named as "Arbitrary SQL through a custom ResultSource" Peace of text:

Arbitrary SQL through a custom ResultSource


<...> your query is too complex (e.g. it contains Unions, Sub-Selects, Stored Procedures, etc.) <...> get the results as a DBIx::Class::ResultSet. <...>defining a separate ResultSource for your query.
Example of complex query:
Class code
package My::Schema::User; use base qw/DBIx::Class/; # ->load_components, ->table, ->add_columns, etc. # Make a new ResultSource based on the User class my $source = __PACKAGE__->result_source_instance(); my $new_source = $source->new( $source ); $new_source->source_name( 'UserFriendsComplex' ); # Hand in your query as a scalar reference # It will be added as a sub-select after FROM, # so pay attention to the surrounding brackets! $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 # Finally, register your new ResultSource with your Schema My::Schema->register_source( 'UserFriendsComplex' => $new_source );


You can execute your query using
bind
parameters like this:
my $friends = [ $schema->resultset( 'UserFriendsComplex' )->search( { +}, { bind => [ 12345, 12345 ] } ) ];
10x all for advice! Cookbook it's great!