Relationship count

Questions, tips and tricks and techniques for scripting in Servoy

Relationship count

Postby Morley » Tue Sep 28, 2004 4:14 pm

Is it possible to get a record count for a relationship without actually loading that relationship?

I'm in a situation in which I just want to know the count, not actually go there. I definitely don't want to disturb the current foundset. FMP's Count function would be perfect in this situation.
Morley Chalmers
7Office Inc.
User avatar
Morley
 
Posts: 891
Joined: Fri Apr 25, 2003 4:54 pm
Location: Toronto, Canada

Postby Harry Catharell » Tue Sep 28, 2004 4:27 pm

Hi Morley,

You should still be able to get a related count without displaying a portal or tabpanel for the related records using :
Code: Select all
num_records = parent_to_child.getSize()


Hope this helps
Harry
Harry Catharell
 
Posts: 812
Joined: Fri Sep 26, 2003 10:23 am
Location: Milton Keynes, England

Postby Morley » Tue Sep 28, 2004 4:45 pm

Perfect! Huzzah!! Thanks Harry.
Morley Chalmers
7Office Inc.
User avatar
Morley
 
Posts: 891
Joined: Fri Apr 25, 2003 4:54 pm
Location: Toronto, Canada

Re: Relationship count

Postby itgenetics » Wed Jan 04, 2012 9:14 pm

Still a great answer :)
itgenetics
 
Posts: 63
Joined: Fri Apr 08, 2011 11:26 am
Location: Cambridge, UK

Re: Relationship count

Postby Peter de Groot » Thu Jan 05, 2012 9:31 am

But what if there are more then 60 related records, if I am correct relationname.getSize() doesn't count further then 60.

Regards,

Peter
User avatar
Peter de Groot
 
Posts: 215
Joined: Thu Jan 10, 2008 8:38 pm
Location: Not sure...

Re: Relationship count

Postby ROCLASI » Thu Jan 05, 2012 10:22 am

The answer to Morley is from 2004 so this is a very very old thread.

But yes, getSize() will only show the amount of PK's loaded. If you really want to know the real foundset size you should use databaseManager.getFoundsetCount(foundset) which is the equivalent of SELECT count(pk) etc. .
Robert Ivens
SAN Developer / Servoy Valued Professional / Servoy Certified Developer

ROCLASI Software Solutions / JBS Group, Partner
Mastodon: @roclasi
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5438
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: Relationship count

Postby Peter de Groot » Thu Jan 05, 2012 11:09 am

I know it's an old post, but I replied because:

Re: Relationship count

by itgenetics » 04 Jan 2012 21:14
Still a great answer :)


Regards,

Peter
User avatar
Peter de Groot
 
Posts: 215
Joined: Thu Jan 10, 2008 8:38 pm
Location: Not sure...

Re: Relationship count

Postby Harjo » Thu Jan 05, 2012 1:04 pm

And to be more specific, by the touching the relation this way, WILL trigger a query to load the related data first, also when you only need the count....... ;-)
Harjo Kompagnie
ServoyCamp
Servoy Certified Developer
Servoy Valued Professional
SAN Developer
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Re: Relationship count

Postby itgenetics » Fri Jan 06, 2012 4:32 pm

I did not realise that it would only pull in 60 records - the updated step has improved the situation..
itgenetics
 
Posts: 63
Joined: Fri Apr 08, 2011 11:26 am
Location: Cambridge, UK

Re: Relationship count

Postby itgenetics » Fri Jan 06, 2012 4:37 pm

ROCLASI wrote:The answer to Morley is from 2004 so this is a very very old thread.

But yes, getSize() will only show the amount of PK's loaded. If you really want to know the real foundset size you should use databaseManager.getFoundsetCount(foundset) which is the equivalent of SELECT count(pk) etc. .


So how would this work in a calculation?

return databaseManager.getFoundsetCount(prd_to_bom.bom_pk)

prd_to_bom is relationship between the product database and mom is a bill of materials database

or am I off the mark?
itgenetics
 
Posts: 63
Joined: Fri Apr 08, 2011 11:26 am
Location: Cambridge, UK


Return to Methods

Who is online

Users browsing this forum: No registered users and 10 guests

cron