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
AmandaAAmandaA 

Help with SOQL query LIMIT

I have a query that returns info that I need to paginate. I can return all records or limit to however many records I'd like, but I'd like to set up a page system that allows me to return a specified number of records and then dynamically create a page numbering system of links at the bottom of the report to go to additional pages of records. I have the whole system set up and working, but cannot figure out how to retrieve records starting after the records I've already retrieved.
 
For example,...
 
Page one shows the first 20 records.
 
Page two should show the next 20, but I need something equivilent to SQL's LIMIT 20,20 to start my query at record #20 and then retrieve 20 records. Does SOQL have a function like this?
 
Thank you all very much in advance.
werewolfwerewolf
Don't set the LIMIT.  Set your batch size instead.  Save your query locator across pages and call queryMore.
Cool_DevloperCool_Devloper

Hi,

I too have a similar requirement where i want to show some 20 records on the first page and show the rest on another page by giving a link "More Records" on the first page.

I am using Visualforce to render this page. Can you please give me some pointers on how i can achieve this??

Thanks in advance .......

Cool_D

LinuxGeexLinuxGeex

SOQL seems to give no way to start with record 500,000 of 1,000,000  

 

Instead we are invited to iterate over the first 500,000 objects and discard them.  Seems wasteful.

 

Is anyone aware of a straightforward answer? 

sforcenewbiesforcenewbie

Hello,

 

I am interested in this as well. Is there a solution for this?

 

Thanks

msimondsmsimonds

From what I know there is no way to pull a set series of records like using rowcount in Oralce

 

You have to iterate over the entire record set

 

~Mike