on 06-26-2015 8:12 AM
select * from ( {{select {ao.pk},{cpf.numbervalue} "account" from {ConfiguredProductFeature as cpf join orderentry as oe on {cpf.orderentry}={oe.pk} join order as ao on {oe.order}={ao.pk}} where {qualifier} = 'account_number'}} ) acc
The above query is running fine but if i change it toselect {acc.pk} from ( {{select {ao.pk},{cpf.numbervalue} "account" from {ConfiguredProductFeature as cpf join orderentry as oe on {cpf.orderentry}={oe.pk} join order as ao on {oe.order}={ao.pk}} where {qualifier} = 'account_number'}} ) acc
I also tried but no luckselect {acc.pk} from ( {{select {ao.pk},{cpf.numbervalue} "account" from {ConfiguredProductFeature as cpf join orderentry as oe on {cpf.orderentry}={oe.pk} join order as ao on {oe.order}={ao.pk}} where {qualifier} = 'account_number'}} ) as acc
This gives me exception: cannot find (visible) type for alias acc within [].The documentation says we can do it like this: https://wiki.hybris.com/display/release5/FlexibleSearch+Samples#FlexibleSearchSamples-SubselectoverS... under "Reporting query with subselect"
The only problem in your FS Query is the use of {}
with acc.pk
i.e. the correct query is:
select acc.pk from ( {{select {ao.pk},{cpf.numbervalue} "account" from {ConfiguredProductFeature as cpf join orderentry as oe on {cpf.orderentry}={oe.pk} join order as ao on {oe.order}={ao.pk}} where {qualifier} = 'account_number'}} ) acc
If you do not have the itemtype, ConfiguredProductFeature
to test it at this point of time, you can replicate the issue with following examples:
Correct
SELECT INNERTABLE.PK, INNERTABLE.CatCode FROM
(
{{
SELECT {p:PK} AS PK, {c:code} AS CatCode FROM
{
Product as p JOIN CategoryProductRelation as rel
ON {p:PK} = {rel:target}
JOIN Category AS c
ON {rel:source} = {c:PK}
}
}}
) INNERTABLE
Incorrect
SELECT {INNERTABLE.PK}, INNERTABLE.CatCode FROM
(
{{
SELECT {p:PK} AS PK, {c:code} AS CatCode FROM
{
Product as p JOIN CategoryProductRelation as rel
ON {p:PK} = {rel:target}
JOIN Category AS c
ON {rel:source} = {c:PK}
}
}}
) INNERTABLE
By executing the incorrect one, you will get following error message:
Exception message: cannot find (visible) type for alias INNERTABLE within []
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
arvind-kumar-avinash that was helpful. I could create a inner query of my own using your sample.
Thanks you.
Curly brackets are parsed by the FlexibleSearch implementation and mapped to the real table name. Since "acc" is just an alias and not an item-type FlexibleSearch simply does not know what to do with it.
Here's a very basic example how to alias the result of a subquery (in my case: "x"):
SELECT x.PK FROM ({{ SELECT {product:PK} AS PK, 'test' AS test FROM {Product AS product} }}) x
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.