Showing objects with empty childobject

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
Rem
Posts: 216
Joined: Wed Oct 03, 2007 8:58 am
Location: Sweden
Contact:

Showing objects with empty childobject

Post by Rem »

(Maybe a simple question, or we may overthink this a bit so bear with us..)

We are trying to run query wich will show all objects thas has a certain childobject as undefined.

The childobject is multiple.

We have tried several approached but the best we can come up with is a calculated field which SHOWS the object which HAS somthing in this child object (which is the opposite of what we are trying to do).

Basically we are writing an errand system and we want to show which customer that has no errands, which could indicate that something in wrong, since there should be no customers with 0 errands
Regards
Rune

Image
weblike
Posts: 1165
Joined: Sun Dec 02, 2012 12:00 pm
Location: Europe

Re: Showing objects with empty childobject

Post by weblike »

FIND Parent_BO WHERE COUNT Child_BO WHERE (Child_BO IN Parent_BO.Childs)=0
Thx,
George
________________________________
Developer Edition
AwareIM: v8.5, build 2824
OS: Windows Server 2012
DB: MySql 5.6.42
tford
Posts: 4238
Joined: Sat Mar 10, 2007 6:44 pm

Re: Showing objects with empty childobject

Post by tford »

You can add an attribute to the parent BO to count the children and add a rule to keep that attribute up to date with the number of children.

Use that counter in your query.

I typically use the counter approach as I find that I want to know that info @ multiple times.
Tom - V8.8 build 3137 - MySql / PostGres
Rem
Posts: 216
Joined: Wed Oct 03, 2007 8:58 am
Location: Sweden
Contact:

Re: Showing objects with empty childobject

Post by Rem »

Thanks!

Solved the problem!

Been away for 7 years so have to wrap my head arround this again!
Regards
Rune

Image
Rem
Posts: 216
Joined: Wed Oct 03, 2007 8:58 am
Location: Sweden
Contact:

Re: Showing objects with empty childobject

Post by Rem »

weblike wrote:FIND Parent_BO WHERE COUNT Child_BO WHERE (Child_BO IN Parent_BO.Childs)=0
Thanks!

This also helped!
Regards
Rune

Image
Post Reply