You need to sign in to do that
Don't have an account?
sfdc dev 2264
Method does not exist or incorrect signature: Database.QueryLocator
Hi,
I am getting the following error in my batch class start method klet me know whats the issue
Error: Compile Error: Method does not exist or incorrect signature: Database.QueryLocator(List<Contract__c>) at line 10 column 16
global class BatchTriggerHandler implements Database.Batchable<sObject> {
Set<Id> contractIdSet = new Set<Id>();
// Constructor will take set of new Contract IDs
global BatchTriggerHandler(Set<Id> contractIdSet){
this.contractIdSet = contractIdSet;
}
global Database.QueryLocator start(Database.BatchableContext bc) {
// Query all Contract records that were in Trigger.new
return Database.QueryLocator([SELECT Status__c, Account__c FROM Contract__c WHERE Id IN :contractIdSet]);
}
let me know whats the issue
Kindly help me
thanks
I am getting the following error in my batch class start method klet me know whats the issue
Error: Compile Error: Method does not exist or incorrect signature: Database.QueryLocator(List<Contract__c>) at line 10 column 16
global class BatchTriggerHandler implements Database.Batchable<sObject> {
Set<Id> contractIdSet = new Set<Id>();
// Constructor will take set of new Contract IDs
global BatchTriggerHandler(Set<Id> contractIdSet){
this.contractIdSet = contractIdSet;
}
global Database.QueryLocator start(Database.BatchableContext bc) {
// Query all Contract records that were in Trigger.new
return Database.QueryLocator([SELECT Status__c, Account__c FROM Contract__c WHERE Id IN :contractIdSet]);
}
let me know whats the issue
Kindly help me
thanks
Use return Database.getQueryLocator instead of Database.QueryLocator in start method.
And write another two method(execute & finish) for batch class. After that your class will be completed.
1.)
global void execute(Database.BatchableContext BC, List<sObject>scope)
{
// Logic to be Executed batch wise
}
2.) global void finish(Database.BatchableContext BC)
{
// Logic to be Executed at finish
}
Mark as a best answer, It solves your problem.
Thanks,
Arvind Kumar
All Answers
Use return Database.getQueryLocator instead of Database.QueryLocator in start method.
And write another two method(execute & finish) for batch class. After that your class will be completed.
1.)
global void execute(Database.BatchableContext BC, List<sObject>scope)
{
// Logic to be Executed batch wise
}
2.) global void finish(Database.BatchableContext BC)
{
// Logic to be Executed at finish
}
Mark as a best answer, It solves your problem.
Thanks,
Arvind Kumar
Hi SFDC Dev 2264 ,
use the below code
String query='SELECT Status__c, Account__c FROM Contract__c WHERE Id IN :contractIdSet';
Database.QueryLocator(query) .
Basically database.query allows you to make a dynamic SOQL query at runtime. You can build up a string and then use that as a query string at run time in the database.query statement to make a SOQL call that is determined at run time.
Database.QueryLocator needs a string input not a soql query inside.
see this reference for better understanding
https://developer.salesforce.com/forums/?id=906F00000008oIlIAI
Thanks and Regards,
Shiva RV
// The execute method will call three methods
global void execute(Database.BatchableContext bc, List<Contract__c> scope) {
ContractfieldsupdateonAccount(scope);
contractcommencementdate(scope);
contractexpirydate(scope);
List<Contract__c> listtoinsert = new List<Contract__c>();
listtoinsert.add(scope);
try
{
Database.Insert(listtoinsert);
}
catch(Exception e)
{
System.debug('Exception Occured: '+e.getMessage());
}
for which i am getting following error
Error: Compile Error: Incompatible element type List<Contract__c> for collection of Contract__c at line 20 column 9
line 20 is
List<Contract__c> listtoinsert = new List<Contract__c>();