You need to sign in to do that
Don't have an account?
Raviteja
Dynamic SOQL Help
Hi ,
I have wrote some code to call the Batch Apex,problem with SOQL Query.
OwnerReassignment reassign = new OwnerReassignment();
datetime myDate = datetime.newInstance(2013, 5, 1);
string site='Amazon Web Services';
string stus ='open';
reassign.query = 'select lastname,ownerid,country,Territory__c,company from lead where CreatedDate > :myDate AND status=:'+stus+ 'AND Site__c!=:'+site;
reassign.email='XXX@XXX.com';
ID batchprocessid = Database.executeBatch(reassign);
Getting System.QueryException: unexpected token: Site__c
Help me to Write SOQL,Thanks in advance...
reassign.query = 'select lastname,ownerid,country,Territory__c,company from lead where CreatedDate > :myDate AND status = :stus AND Site__c != :site';
Same result...
System.QueryException: Variable does not exist: myDate
try to change myDate to string into format like in database 2013-05-30T00:46:19.000Z
String myStringDate = myDate.formatGMT('yyyy-MM-dd\'T\'hh:mm:ss\'Z\'');
reassign.query = 'select lastname,ownerid,country,Territory__c,company from lead where CreatedDate > '+myStringDate+' AND status=\' '+stus+ ' \' AND Site__c!= \' '+site+' \' ';
FROM Account
WHERE CreatedDate > 2005-10-08T01:02:03Z