I'm trying to form a query in SOQL.
In scheduler ..
sch.accountdList = AccList;
sch.query = 'SELECT id from Account where ID IN :';
Database.executeBatch(sch,200);
and in Batch start..
query=query+AccList;
return Database.getQueryLocator(query);
This gives me this error
Only variable references are allowed in dynamic SOQL/SOSL
So I tried to avoid ":"
In scheduler again..
sch.accountdList = AccList;
sch.query = 'SELECT id from Account where ID IN /'';
I get this error:
mismatched character 'EOF' expecting
How should I form the query? Where am I going wrong?
Thanks in advance!
Best Answer
I was also facing same kind of issue. Please find below code snippet to work.
Scheduler class: sch.accountList = accountList;
batch class
global List accountList = new List(); start() { query = 'select id from account where id in :accountList'; }
This is working for me.