You need to sign in to do that
Don't have an account?
MG Consulting
No Binding Variables in Dynamic SOQL
Hi,
I just noticed that bind variables are not allowed in Dynamic SOQL. I'd like to be able to pass in a set of Ids, i.e. getLeadIds() and then dynamically vary the subsequent part of the Where clause, i.e. City = 'Boston'.
Is there any good way to pass a set of Ids to a Dynamic SOQL statement?
Do I just have to resort to looping through the set of Ids and adding them to the query string in the required format, i.e. ('id1', 'id2')?
Seems a bit cumbersome, so just wondering if anyone had some better ideas on how to handle this.
Thanks a lot,
Mike
I just noticed that bind variables are not allowed in Dynamic SOQL. I'd like to be able to pass in a set of Ids, i.e. getLeadIds() and then dynamically vary the subsequent part of the Where clause, i.e. City = 'Boston'.
Code:
Database.query('SELECT Name FROM Lead WHERE Id IN :getLeadIds() AND City = \'Boston\'');
Is there any good way to pass a set of Ids to a Dynamic SOQL statement?
Do I just have to resort to looping through the set of Ids and adding them to the query string in the required format, i.e. ('id1', 'id2')?
Seems a bit cumbersome, so just wondering if anyone had some better ideas on how to handle this.
Thanks a lot,
Mike
Jeremy Kraybill
Austin, TX
http://wiki.apexdevnet.com/index.php/Apex_and_Visualforce_Security_Tips#SOQL_Injection