function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Juan RomeroJuan Romero 

Aggregate functions (Count)

Hi everyone,

Is it possible to query the server through the XMLRPC to get an aggregate function such as "COUNT"?

In concrete, I would like to know the number of records in a given table by issuing a command.

I have not seen anything like that on the manual, so I am currently doing it by issuing a query of 1 field only, and counting the results (which is most definitely not recommended)

Thank you in advance, I appreciate your help.

 

alal

For what its worth,

We have to do this same thing.

Since we get the record ID's back in an XML document, we just use the XML parsers 'selectNodeList' method to parse the xml.

VB, VC, Java, and Perl all have this same function when using an xml DOM library. (MSXML, Xerces/Xalan, Expat-derivatives, etc.)

You get back a collection of data from the selectNodeList call and you can just get the 'count' of

the nodes without having to iterate.

If you can supply your platform and language details I can easily create a code sample for you if it would help.

You can also use the XML parser to handle searching sforce API results, find the top n values returned, and any of the

other SQL-like aggregate functions you would need.

 

Now, if we just had the ability to query using a function like JOIN...

 

Al G

AlterPoint

 

Juan RomeroJuan Romero

Thank you for your response.

That is exactly what I am doing now, but the problem is the impact in performance, since even if I query for one field only, it still has to bring information back. For instance, I have a table with 10K + records, so in order to count them , I have to retrieve 10K+ IDs.....

I just use the GetElementsByName method of the DOM Parser to get the count.

I am doing my JOINS locally (since there is nothing like it in SalesForce), so in order to have updated information I created a system that retrieves table structures, updates, imports, etc information from SalesForce.

Good Luck!