Discussions
- General Development
- Schema Development
- Apex Code Development
- Visualforce Development
- Formulas & Validation Rules
- Security
- Mobile
- Force.com Sites & Site.com
- Chatter Development
- Java Development
- .NET Development
- Perl, PHP, Python & Ruby
- Desktop Integration
- APIs and Integrations
- Visual Workflow
- Apple, Mac and OS X
- VB and Office Development
- AppExchange Directory & Packaging
- Salesforce Labs & Open Source Projects
- Other Salesforce Applications
- Jobs Board
- Force.com Discussion Boards
- :
- Developer Boards for Force.com and Database.com
- :
- Apex Code Development
- :
- Database.getQueryLocator(String) truncates WHERE f...
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Database.g etQueryLoc ator(Strin g) truncates WHERE from Query String
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-24-2013 05:54 PM
I'm running a batchprocess that works except it does not use the where clause in the query. Is there some kind of pitfall that I should be aware of with Database.getQueryLocator and Where clauses?
Anybody...
Solved! Go to Solution.
Re: Database.g etQueryLoc ator(Strin g) truncates WHERE from Query String
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-24-2013 06:24 PM
Do a system.debug to get the SOQL query and then paste it into Salesforce workbench or other tool to see if it looks right and returns what you expect. The Where clause works fine in batch apex
Re: Database.g etQueryLoc ator(Strin g) truncates WHERE from Query String
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-24-2013 06:27 PM
When I check the logs it actually shows the WHERE clause as truncated:
17:50:59.076 (76328000)|USER_DEBUG|[39]|DEBUG|Within BatchProcesses start method 17:50:59.076 (76340000)|SYSTEM_METHOD_EXIT|[39]|System.debug(ANY) 17:50:59.076 (76372000)|SYSTEM_METHOD_ENTRY|[44]|System.debug(A NY) 17:50:59.076 (76394000)|USER_DEBUG|[44]|DEBUG|The query string is SELECT Customer_Status__c, Auto_Archived__c, LastActivityDate, Id, Has_Open_Activity__c, Prefers_to_Work_with_Associated_Agent__c, Status, FirstName, LastName, State, OwnerId, IsConverted FROM Lead WHERE IsConverted!=true AND (Customer_Status__c!='Contact Attempt 1' OR Customer_Status__c!='Contact Attempt 2') 17:50:59.076 (76407000)|SYSTEM_METHOD_EXIT|[44]|System.debug(AN Y) 17:50:59.076 (76430000)|SYSTEM_METHOD_ENTRY|[45]|Database.getQu eryLocator(String) 17:50:59.077 (77493000)|SOQL_EXECUTE_BEGIN|[45]|Aggregations:0| SELECT Customer_Status__c, Auto_Archived__c, LastActivityDate, Id, Has_Open_Activity__c, Farmers_Agent_Test_Lead__c, Prefers_to_Work_with_Associated_Agent__c, Status, FirstName, LastName, State, OwnerId, IsConverted FROM Lead 17:50:59.191 (191179000)|SOQL_EXECUTE_END|[45]|Rows:9 17:50:59.191 (191250000)|SYSTEM_METHOD_EXIT|[45]|Database.getQu eryLocator(String) 17:50:59.889 (306976000)|CUMULATIVE_LIMIT_USAGE
Re: Database.g etQueryLoc ator(Strin g) truncates WHERE from Query String
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-25-2013 09:43 AM
What you are seeing is an artifact of the debug log Spring 13. The where clause is executing - I tried on my own data and it works fine
As an aside, I'm always telling folks on this forum to use system.debug to aid in understanding and in this case, the debug log itself is misleading
Re: Database.g etQueryLoc ator(Strin g) truncates WHERE from Query String
[ Edited ]
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-25-2013 09:50 AM - edited 01-25-2013 09:52 AM
What do you mean by system.debug, is that an aspect of the developer console. I am more familiar with the development directly in Sandbox. Also, when I run it I see way more rows returned than would be if the where clause were being used.
Re: Database.g etQueryLoc ator(Strin g) truncates WHERE from Query String
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-25-2013 10:49 AM
Using the Query Editor on the developers console I was able to debug the issues I was having. You were correct about the debug logs being erroneous, my issue also arose from a mistake I had made in the where clause.
Re: Database.g etQueryLoc ator(Strin g) truncates WHERE from Query String
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-25-2013 02:43 PM
you are welcome; pls mark as 'solved'

