+ Start a Discussion
sfdcFanBoysfdcFanBoy 

dynamic soql : unexpected token '{'


Im getting the following error

System.QueryException: unexpected token: '{'

here's the simple code.
Set<Id> sId = new Set<Id>{};
sId.add('a0df000000063A9AAI');
sId.add('a0df00000006P2cAAE');
String squery = 'SELECT Id, Name FROM Engagement__c  WHERE Id IN:'+sId;
List<Engagement__c> lst = database.query(squery);   
System.debug('----list size:'+lst.size());


Sonam_SFDCSonam_SFDC
Please use Set<Id> sId = new Set<Id>(); instead of Set<Id> sId = new Set<Id>{};