cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ERQL: find entity "daughters" of an entity

Solved
Highlighted
Occasional Contributor

ERQL: find entity "daughters" of an entity

Dear all,

 

To build a Publisher document, I need some registered queries on "Enity (DM)".

I have some difficulties for one query: How to list all entities linked to an entity and considered as "Daughters"?

 

For example If I have an entity CAR, I have WHEEL, STEERINGWHEEL and CARSEAT.

And I have another entity nammed GARAGE where I park several CAR.

 

And if I try the following ERQL :

 

Select

[Entity (DM)] Where [Association (DM) via AssociationEnd].[Entity (DM) via AssociationEnd]=&"EntityNameFilter"

And

[Name] Not=&"EntityNameFilter"And [Diagram].[Association (DM)].[Potential Mapping] Like"K"

And

[Diagram].[Association (DM)].[Entity (DM) via AssociationEnd] =&"EntityNameFilter"

 

The result is : GARAGE, CARSEAT, WHEEL and STEERINGWHEEL. 

Instead of only : CARSEAT, WHEEL, STEERINGWHEEL.

 

How can I filter GARAGE ?

 

Thanks all ! Smiley Very Happy

2 Replies
MEGA

Re: ERQL: find entity "daughters" of an entity

Hello vlevasseur

 

To select the list of entities (Entity (DM)) connected to a source entity (ex: Car) via an association, you can use such a query

 

Select [Entity (DM)] Into @1 Where Name=&C
Select [Entity (DM)] Into @2 Where [AssociationEnd (DM)].[Association (DM)].[AssociationEnd (DM)].[Entity (DM)]=&C
Select [Entity (DM)] From @2 And Not @1

The select#1 and select#2 are used only to remove the source entity (ex: car)  from the list.

 

Daughter entity is not a clear definition.

If we consider that we want to select the list of entities (Entity (DM)) connected to a given entity (ex: Car) via an association where the association end is an aggregation (Whole/Part=Y) or a composition (Whole/Part=C), you can use such a query

 

Select [Entity (DM)] Into @1 Where Name=&C
Select [AssociationEnd (DM)] Into @2 Where ([Whole/Part]="Y" Or [Whole/Part]="C") And [Entity (DM)]=&C
Select [Entity (DM)] Into @3 Where [Association (DM) via AssociationEnd].[AssociationEnd (DM)] in @2
Select [Entity (DM)] From Not @1 And @3

 

These queries will not consider reflexive association (association (DM)).

 

If you need to add many criteria, using the ERQL language may become difficult.

You can then consider to use a macro to implement the query.

 

Jerome
Occasional Contributor

Re: ERQL: find entity "daughters" of an entity

Thanks Jerôme for your answer.

 

Yes using macro will become a good option for newt requests !

 

Vincent