Salesforce(apex) Query select with Where toLowerCase

大城市里の小女人 提交于 2020-01-15 05:56:08

问题


I using Salesforce (apex), I need to Query with a WHERE statement with toLowerCase ,i.e. I have a list (MyNames_list) with LowerCase values but the table values are not lowerCase.

In my Query when I check the Name in MyNames_list it will make toLowerCase value and then check it in the MyNames_list.

Something like this:

Name | LastName

BOBY | Testovich1

DANY | Testovich2

Ron  | Testovich3

and in my list:

MyNames_list :boby,dany,ron

That still will return me all rows, because WHERE statement will check it with LowerCase.

//only example (not working code)

for(Users user:[SELECT Name,LastName FROM Users 
                WHERE ( Name.toLowerCase() IN : MyNames_list) ] )
{  
    //code....
}  

Is there a way to do this in Salesforce (apex) Query ?


回答1:


Salesforce is only case-sensitive for fields that are explicitly case-sensitive (ie an external id that has been marked as case-sensitive)

The field you are querying, Name is not case-sensitive - hence, you don't need to apply toLowerCase(). You will get all matching fields anyway.

So your query could be:

for(User u:[SELECT Name,LastName FROM User WHERE Name IN :MyNames_list)]){  
//code....
}  


来源:https://stackoverflow.com/questions/39557852/salesforceapex-query-select-with-where-tolowercase

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!