Questions tagged [querylocator]

Represents the record set returned by Database.getQueryLocator and used with Batch Apex.

Filter by
Sorted by
Tagged with
1
vote
1answer
37 views

OFFSET limit exceeds while implementing pagination for listing of users

Currently, we are trying to populate all users of salesforce in a Visualforce Page with page per limit of 1000 using Database.getQueryLocator (shown below) Database.getQueryLocator('select Id,...
3
votes
2answers
32 views

QueryLocator crashes after casting to Iterable and executing .iterator()

So here is some simple code that does work: Database.QueryLocator ql = Database.getQueryLocator('SELECT Id FROM Account LIMIT 2'); Iterator<SObject> iter = ql.iterator(); Ok. But suppose I ...
0
votes
1answer
18 views

How can I make my <account> variable filterType equal to the first account returned in a StandardSetController Query?

how would this work with a dynamic search page I have a visual force search page and I have used the stadardsetcontroller for pagination. The initial query during page load is working for me. ...
3
votes
2answers
133 views

Where do queries [SELECT …] return QueryLocator instead of List<SObject>?

As a Salesforce Apex developer, it is frequently desirable to have a QueryLocator instead of a List in order to overcome certain governor limits. Moreover, for a variety of reasons, it can be ...
7
votes
3answers
174 views

Is there a typesafe way to get a Database.QueryLocator?

Normally, to select things we use SOQL code like: [ SELECT Id, Blah1__c, Blah2__c, Blah3__c FROM Yada_Yada_Yada__c WHERE Id IN :idSet ]; When we do this, the compiler (and our IDEs) ...
-2
votes
1answer
141 views

Query more than 50000 records in a normal class

I need to query more than 50000 records and store it in a List variable. i know there is a governor limit which prevents it. please let me know if this can be accomplished without going for a batch ...
1
vote
0answers
101 views

Database.querylocater on external object in batch class not returning any rows

I am writing a batch class on external object. Here I am using database.getQuerylocator in start method as the result will contain more thank 50k records. Batch class code: global class <...
0
votes
1answer
83 views

Batch Apex ignores records even without subquery in start()

Basically the querylocator returns about 200000 records at the start, I can see it in logs, also there are not any errors or limits warnings. The size of each job matters because the smaller it is,...
1
vote
1answer
601 views

queryLocator - Use date variable

First off, I am not sure how to properly refer to this type of SOQL query. I am working on a batch process and this is the step where you build the query. What I am having trouble with is putting in ...
0
votes
1answer
297 views

Does an Inner Query in Query Locator count towards row governor limit?

The limit with regards to rows in a query locator is 50 million. Does using an inner query reduce the number of possible rows? For example: Query for Query Locator: SELECT Id, (SELECT Id FROM Orders)...
2
votes
1answer
379 views

Does QueryLocator work with Big Objects?

I am trying to query Big Object records through Database.getQueryLocator method in a Batch class. However, it is throwing an 'Internal Salesforce Error' on the queryLocator line. I tried executing ...
0
votes
1answer
464 views

Batch Apex Chaining Limits?

I'm planning to perform apex batch chaining since I will be working on around 3-4 objects with total records probably crossing 50 millions. I'll be doing something similar to this: How to update 2 ...
0
votes
1answer
891 views

Batch class String query does not allow a set filter

I am working on updating a batch class where I do a query for records and pass them to another class to handle the logic. I want to include a line where the record Id is not in a string set. (I am ...
3
votes
0answers
99 views

Execute Method in Batchable Class does not execute on all records returned in Start method Querylocator

I am seeing a very similar issue to the one discussed in this question, which was due to a bug in Spring '17. The Querylocator returned by the Start method returns 9,989 records, which I can verify ...
1
vote
0answers
87 views

QueryLocator timeout problem?

I have a StandardSetController that I navigate through pages... from a VF page. However, if I let the web page sit for around 15 min or so (not sure about the time) and then try and click the next or ...
0
votes
1answer
116 views

Exception thrown by StandardSetController with Database.getQueryLocator? [closed]

I am using a StandardSetController with Database.getQueryLocator to call my query. I am wondering what can go wrong in this code snippet, i.e. what is the Exception that has a probability of being ...
0
votes
2answers
329 views

Query exception - Unexpected token '{'

I have below query string in an apex batch class that throw error. Can some one please help? Error Unexpected token '{' Query String String query = 'SELECT Call_Duration_Required_abv__c,Id FROM ...
1
vote
2answers
551 views

How to Delete Records in a object except Newly created 1000 Records by using Batch Class?

I have a question, how to delete all records except newly created 1000 records(For Eg: in a Account Object i have 11000 records,in that 1000 records are created in this month, now all 10000 records ...
0
votes
1answer
153 views

Risks of replacing SOQL query with QueryLocator [duplicate]

I used to have this block of code in a widely used method: SObject[] ls = Database.query(q); SObject[] children = new SObject[]{}; for (SObject l : ls) { for (SObject c : l.getSObjects('...
3
votes
2answers
463 views

Inconsistency with error “Aggregate query has too many rows for direct assignment”

I have a Box__c record with 100 Doors__r, 104 Motors__r, and 0 Wheels__r. ISSUE #1 I am getting the error System.QueryException: Aggregate query has too many rows for direct assignment, use FOR ...
0
votes
2answers
2k views

illegal assignmet database.querylocator to list<campaign>

I have a batch class, the return type of start method is 'Database.QueryLocator' and I'm returning the follow: global Database.QueryLocator start(Database.BatchableContext bc) { string ...
1
vote
1answer
636 views

Unexpected token '(' error batch apex

global Database.QueryLocator start(Database.BatchableContext BC) { String query = 'select id,ParticipantName__c,EpisodePoPEndDate__c from BPCIAe__c where id in :CHildParentMap.keyset() OR id in :...
6
votes
1answer
746 views

Batch process order of records in execute

It is more of a conceptual question. I have to write a batch process to do some operation on Leads. It is very important that i first take the oldest lead (created date should be oldest) Let's assume ...
2
votes
1answer
336 views

Argument must implement iterable

I have the following apex batch class: global class BatchUpdateListItem implements Database.Batchable<sObject>, Database.AllowsCallouts { global List<UpdateProduct> update_product {...
5
votes
2answers
455 views

What kind of actions open a query locator

We use a batched approach for read and update CampaignMember records within an external application (Webservice Connector, or WSC SOAP API). The approach can be described like this: Query campaign ...
1
vote
0answers
55 views

Get count of open Query Locators

For debugging porpuses, we would like to get the count of the open "QueryLocators" for an organisation.Is this possible somehow? Thanks
9
votes
1answer
153 views

Read access denied: getQueryLocator(soql) vs. query(soql)

I am attempting to add pagination, and I followed this great article by Jeff Douglas. I am an admin so when I run the page it runs great, I can navigate forwards, back. When I log in as a user my ...
1
vote
1answer
66 views

Compile Error: expecting a right parentheses, found ',' at line 22 column 298

Based on the requirement i have written a batch and schedule class for an email notification to be sent before 90 days. I have used the below query in the code ,where i used to get an email ...
10
votes
2answers
7k views

Exception: QUERY_TIMEOUT Your query request was running for too long

Querying on approx 25 million contacts using the following query in database.getQueryLocator. Used Query Resource Feedback (Link) to get some feedback about query and here are the results. Query - 1: ...
0
votes
1answer
464 views

How to call QueryLocator.iterator() twice

I am using a QueryLocator in my code. In one part of the code I call the .iterator() method to verify that it is not empty. Now I am going through writing a unit test and finding that I am unable to ...
0
votes
1answer
745 views

Count records in QueryLocator?

For counting recording of an sObject I would write ... Select count() from obj; But how do I find out the total records in Database.QueryLocator?