DBIx :: Class可以与存储过程而不是表一起使用吗?

ste*_*enl 5 perl stored-procedures dbix-class

通过返回结果集而不是表或视图的mssql存储过程向我提供了从db读取的访问权限.但我希望能够使用ORM读取数据.

我试图使用DBIx::Class::ResultSource::View过程调用(例如EXEC my_stored_proc ?)作为自定义查询,但这不起作用,因为它试图将过程调用转换为select语句.

有人有另一个建议吗?

djs*_*off 6

不,没有合理的方法在DBIx :: Class的上下文中执行存储过程.

据我所知,与解决方法最接近的是"使用ORM"获取数据库句柄,这是一个弱点:

   my @results = $schema->storage->dbh_do(sub{
         my ($storage, $dbh, @args) = @_;
         my $sth = $dbh->prepare('call storedProcNameFooBar()');
         my @data;
         $sth->execute();
         while( my $row = $sth->fetchrow_hashref){
             push @data, $row;
         }
         return @data;
    },());
Run Code Online (Sandbox Code Playgroud)

[详见 http://metacpan.org/pod/DBIx::Class :::Storage :::DBI#dbh_do ]

...因为你没有为你的麻烦获得ORM的好处.