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
MadhanMadhan 

Problem with data SQL query

Hi all,

 

I kind of stuck here. 

 

Problem: I have two tables Account and Website_Profile__c. There are 539 records in the "Website_Profile__c". Since I was not able to use relational queries using PHPToolkit. I was given a reference to the "Website_Profile__c" table in the account table so that I will be able to access the values in the "Website_Profile__c". When I try using the following query,

 

-----------------------------------

 $query = "select Account.Active_Web_Profile__r.Active__c, Account.ID, BillingStreet, Account.Membership_Active_date__c, Account.DBL_Gift_Card__c, Website_Id__c, BillingCity, BillingState, Verified__c, Updated__c, BillingPostalCode, Phone, Account.Name, Account.Website, Industry, Account.Active_Web_Profile__r.Name, Account.Active_Web_Profile__r.ID, Account.Active_Web_Profile__r.History__c, Account.Active_Web_Profile__r.Philosophy__c, Account.Active_Web_Profile__r.Products__c, Account.Active_Web_Profile__r.Account__c, Account.Active_Web_Profile__r.Email__c, Account.Active_Web_Profile__r.Picture__c, Account.Active_Web_Profile__r.Updated__c, Account.Active_Web_Profile__r.Verified__c from Account where Account.Active_Web_Profile__r.Active__c=true ORDER by Account.ID LIMIT 500";

-----------------------------------

 

I get only "250" active records fetched form the Salesforce database instead of "328" active records.

 

Account.Active_Web_Profile__r.Products__c ->  Here the Active_Web_Profile__r is a reference to the "Website_Profile__c" table in the "Account" table which will allows me to access the values from the "Website_Profile__c" table via "Account" table.

 

Why am I not able to fetch all the 328 active profiles?

 

It will be of great help if somebody can tell me where I am going wrong.

 

FYI I am able to access the "328" records from the "Website_Profile__c" table when queried just the single table (Website_Profile__c) and not the relational query.

 

 

Thanks,

Madhan

Best Answer chosen by Admin (Salesforce Developers) 
CaffeineCaffeine

Hello Madhan,

You can't count on the query to return all the records at once.  You must implement QueryMore until all records are returned.  The salesforce engine ultimately determines how many records to return in a batch, so even though in the one case it does return them all, you cannot count on that.

 

See here:

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_querymore.htm

All Answers

CaffeineCaffeine

Hello Madhan,

You can't count on the query to return all the records at once.  You must implement QueryMore until all records are returned.  The salesforce engine ultimately determines how many records to return in a batch, so even though in the one case it does return them all, you cannot count on that.

 

See here:

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_querymore.htm

This was selected as the best answer
MadhanMadhan

Hi  Caffeine,

 

Thanks for your insight on this. 

 

Thanks

Madhan