Tag Archives: soql

SOQL/SOSL: Using NOT LIKE

I’ve had to struggle to remember how to do this enough times that I think it’s worth documenting. Using the LIKE keyword to filter records in a SOQL or SOSL query is a great way to do searching using a … Continue reading

Tagged , , | Comments Off

How to Select Archived Tasks and Events in SOQL

I recently encountered an issued where I could see a Task from within Salesforce.com, but I could not select it with the API. After some further research, I realized that it was qualified as an archived activity — that is, … Continue reading

Tagged , , | Comments Off

SQLForce: an option for Select Distinct in Salesforce

Today I was trying to get a list of distinct values in a field in Salesforce having a certain criteria. If SOQL supported ‘select distinct’, this could be accomplished quite trivially. Of course you can’t do ‘select distinct’ with the … Continue reading

Tagged , , , , , | 1 Comment

Using Batch Apex with non-dynamic (static) SOQL

If you look at the Using Batch Apex guide in the developer docs, all of the examples use Dynamic SOQL, that is SOQL that can be constructed using a String, as in List<Account> accounts = Database.query(‘select id from account limit … Continue reading

Tagged , , | Comments Off

Only Aggregate Expressions Use Field Aliasing

If you’ve ever come across the following error in a SOQL statement in Salesforce: Save error: only aggregate expressions use field aliasing, Force.com save problem The issue is that you forgot a comma in your SOQL query! Indeed this will … Continue reading

Tagged | 10 Comments

System.QueryException: List has no rows for assignment to SObject

I’ve run across this oddity a few times. When you construct a SOQL query thusly Account a = [select id from account where id = ’01pL00000000XXX’]; And if the ID returns no rows, instead of setting the resulting Account record … Continue reading

Tagged , , | Comments Off