If you are executing sql you may wish to consider using dbi directly.


Benjamin Martin wrote:
hello all,

I have a table in my schema that holds SQL queries (horrid I know!). Imagine a table with query_id and query_sql columns.

I want to create a dynamic view within my schema that represents these queries. .. so I will be able to do something like this:

  my $query = $schema->resultset('TableHoldingQueries')->find(1);
  my $view = $query->as_view();
  my $row_from_running_query = $view->search()->first();

So the rough plan is in my 'TableHoldingQueries' Result file, I will create a method called, 'as_view'

  sub as_view
  {
    my $self = shift
    my $view = DBIx::Class::ResultSource::View->new( { .. } );
    $view->result_source_instance->is_virtual(1);
    $view->result_source_instance->view_definition( $self->query_sql );
    return $view;
  }

My problem is that I dont have a clue where to start creating a DBIx::Class::ResultSource::View on the fly in the correct way ... can anyone point me to some docs/examples .. anything ..

Thanks for any help you can provide.

Happy Xmas all =:-D

-B

_______________________________________________
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/[email protected]



_______________________________________________
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/[email protected]

Reply via email to