function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
neao18neao18 

Help In System.QueryException: unexpected token: '['

Hi I am using Dynamic query in Apex and I am facing this issue I have my debug logs:

What am I doing wrong?? This is my query string  --

 

10:17:09.075 (75325000)|USER_DEBUG|[86]|DEBUG|******Select Id,Name,Lookup__c from Record__c where Lookup__c IN  '[a02i00000012UOvAAM, a02i00000012UOfAAM]'

 

Bhawani SharmaBhawani Sharma
Use colon operator after Lookup__c IN
Like

Lookup__c IN : SetIds
neao18neao18

Thanks but WHEN I DO THIS

IN : [a02i00000012UOvAAM, a02i00000012UOfAAM]

 

     

I GET :

 

 IN operator must be used with an iterable expression this error!!

Bhawani SharmaBhawani Sharma
Try one other option
Create a string using set in format
String ids = '(\'' + id1 + '\',\'' + id2 + '\')'

and then use in query
IN ids

Dont use colon this time
APathakAPathak
IN : (a02i00000012UOvAAM, a02i00000012UOfAAM)

 

use round bracket instead of square.

Bhawani SharmaBhawani Sharma
Did it help?
David Lee(China Developer)David Lee(China Developer)
Select Id,Name,Lookup__c from Record__c where Lookup__c IN ('a02i00000012UOvAAM', 'a02i00000012UOfAAM')