You need to sign in to do that
Don't have an account?
krix
How to use a local code variable (preceded by a colon) in SOQL query string (Database.query(str))?
Hi!
I made a procedure that creates an SOQL query string. It occurs dynamically beacause it has user input dependency where clause. The where clause contains an IN operator with an apex local code variable (preceded by a colon). How can we use this variable in the query string?
The problem reduced: How to create this with query string?
List<T__c> L = [SELECT id, status__c FROM T__c WHERE status__c IN :tmpList];
This is not okay:
List<T__c> L = Database.query("SELECT id, status__c FROM T__c WHERE status__c IN " + tmpList );
Thanx, Krix
Check out this blog post (not mine) for examples:
http://www.nimbleams.com/blog/2013/1/29/variable-binding-in-dynamic-soql/
All Answers
Check out this blog post (not mine) for examples:
http://www.nimbleams.com/blog/2013/1/29/variable-binding-in-dynamic-soql/
Thanx for the quick amswer!