[Dbix-class] select * from function('param')
mock
mock at obscurity.org
Fri Jul 28 14:09:31 CEST 2006
On Fri, Jul 28, 2006 at 12:20:54PM +0100, Ash Berlin wrote:
> mock wrote:
> > Yeah, looks like I'm going to have to do the from hackery.
> >
> > So I tried the stupidly obvious:
> >
> > my $rs = $schema->resultset('Getcourses')->search(undef,
> > {
> > from => 'getcourses(\'STUDENT\')',
> > })->first;
> >
> > print "Name ",$rs->name, "\n";
> >
> > Which gives me this error:
> >
> > DBD::Pg::st execute failed: ERROR: missing FROM-clause entry for table "me"
> > DBIx::Class::ResultSet::first(): Error executing 'SELECT me.courseid, me.name, me.seattotal, me.seatleft, me.slot, me.priority, me.availid, me.begindate, me.enddate, me.couponname, me.coupontype, me.coupontotal, me.couponleft, me.price, me.tax, me.currency FROM getcourses('STUDENT')' (): ERROR: missing FROM-clause entry for table "me"
> >
> > On first inspection it looks like it is doing what I want
> > "SELECT * FROM getcourses('STUDENT')"
> > but I don't understand the error message. The documentation talks a lot about
> > custom joins, but that doesn't look like what I'm trying to do. Any hints?
> >
> > mock
> >
> It is expecting:
>
> SELECT ... FROM getcourses('STUDENT') me
>
> but the "me" (table alias) is missing.
>
> Try:
>
> from => 'getcourses(\'STUDENT\') me',
>
> Not sure if there is a proper way of doing that or not tho
>
> -ash
>
my $rs = $schema->resultset('Getcourses')->search(undef,
{
from => 'getcourses(\'STUDENT\') me',
})->first;
print "Name ",$rs->name, "\n";
works!!!!
I owe you a beer. If you're going to YAPC::EU please collect from me.
thanks
mock
More information about the Dbix-class
mailing list