Subject | Re: [firebird-support] Using a query parameter before a sub query |
---|---|
Author | Tobias Grimm |
Post date | 2007-03-06T10:04:52Z |
Helen Borrie schrieb:
constant on the left or the right side, it works with a parameter on the
right side and therefore it should also work with a parameter on the
left side of the subquery.
an option. The above query is generated by NHibernate Criterea Queries.
I can workaround the problem by using a HQL query, so this is currently
not a big show stopper. Maybe I should add an issue to the tracker.
Tobias
> >SELECT count(*) as y0_ FROM Department this_ WHERE ? < (SELECT count(*)I really think, it should work. It's a valid expression, it works with a
> >as y0_ FROM Product this_0_ WHERE this_0_.Department = this_.Number)
> >But it fails when preparing the query with error code 804.
> >Is this a bug in Firebird?
> Yes and no, but not really. The ? symbol is a replaceable parameter,
> not a variable. So a constant in that spot works, whereas a
> non-typed unknown "thing" doesn't.
constant on the left or the right side, it works with a parameter on the
right side and therefore it should also work with a parameter on the
left side of the subquery.
> But I'm dead suspicious about what you want from this query.It's simply querying the number of departments that contain products.
> perhaps what you are really after is the following:I'm working with FbEmbedded wnd NHibernate as ORM mapper, so this isn't
>
> SELECT count(*) as y0_ FROM Department this_
> where exists (
> select 1 from Product this_0_
> where this_0_.Department = this_.Number)
an option. The above query is generated by NHibernate Criterea Queries.
I can workaround the problem by using a HQL query, so this is currently
not a big show stopper. Maybe I should add an issue to the tracker.
Tobias