The Silver Lining

Lessons & Learnings from a salesforce certified technical architect.

Posts Tagged ‘soql

SOSL, friend or foe?

with 2 comments

As requested by Chris Peterson I’d like to dig a bit more into SOSL. This is as much a lesson for me as anyone else, and I’d be ecstatic if anyone out there could offer a bit more depth on the topic. SOSL (or sossel) is Salesforce’s search language, and in my experiences definitely has it’s advantages(which are significant in the CRM) and limitations(which may stem from me/us just not knowing how to use it properly). First let’s make sure you have the standard docs memorised.

Basic doc on SOSL within Apex code

API doc, thorough on syntax although might not have some common examples.

Doc for dynamic SOSL

Right, now that we have those committed to memory we can delve into what I think are the advantages and disadvantages of SOSL.. Read the rest of this entry »

Advertisements

Written by Wes

October 10, 2009 at 5:08 pm

Handling System.QueryException

with 5 comments

When attempting to fetch a single record from the database it is easy to run into the above exception. I’ve seen two schools of thought in dealing with this issue – mostly in the forums – and have been hoping to find a more official standpoint. Read the rest of this entry »

Written by Wes

July 9, 2009 at 1:04 pm

How to avoid Governor Limits [Part 1 of N]

with 5 comments

This topic is waaaay too big to cover in one post, so for now I’m going to concentrate on avoiding this particular exception: ‘Too many SOQL queries’. I will also touch on the ‘Too many DML rows’ exception, and expand on it’s solutions in another post. Bulkifying your triggers is another topic I will cover at some later date, but the methodologies mentioned here should go some way towards helping you avoid some of the Governor Limits there too.

Read the rest of this entry »

Written by Wes

July 1, 2009 at 2:55 pm

SOQL ‘Distinct’ Keyword

with 16 comments

It doesn’t exist. Sad but true.

In SQL there is a clause that ensures a duplicate free result set is returned by any query you issue e.g. You want to retrieve a duplicate free list of first names from the table clients. The column holds the following values: Alice, Bob, Alice. In Oracle SQL you would use the following query (and it would return the names Alice and Bob each listed once)

SELECT DISTINCT firstname
FROM clients;

Unfortunately SOQL doesn’t have this capability although there is an Apex trick that can be employed as a work-around. Read the rest of this entry »

Written by Wes

June 28, 2009 at 3:54 pm

Posted in Apex, SOQL

Tagged with , , , , ,

Salesforce Savepoints

with 5 comments

Transaction control is an important part of any system that interacts with a database and Salesforce has neat ways of implementing said control.

Anyone that’s worked with SQL databases will be familiar with savepoints and rolling back, and Salesforce has implemented similar constructs. For those who haven’t heard of these terms wikipedia describes them as

savepoint is a way of implementing subtransactions (also known as nested transactions) within a relational database management system by indicating a point within a transaction that can be “rolled back to” without affecting any work done in the transaction before the savepoint was created.

rollback is an operation which returns the database to some previous state.

As with most things, the importance of these two features is best demonstrated using examples. Read the rest of this entry »

Written by Wes

June 15, 2009 at 7:28 am

%d bloggers like this: