February 27, 2009

SOQL with Dataloader

How do you execute SOQL? Compared to SQL, where we have our beloved interfaces depending on the RDBMS, SOQL is a lot more tricky to even find an environment to execute it. A good refrence for SOQL is here, but so far have had much more limited sucess actually executing the SOQL.

In my developer account, I go to Setup > Administrative Setup > Data Management > DataLoader. The actual URL is here if : https://na6.salesforce.com/dwnld/DataLoader/ApexDataLoader.exe - but that may vary per SFDC account.

Step 1: (pdf) RTFM!

Step 2. Start DataLoader, log in with your API enabled account.

Step3. Go to Export section to run the SOQL.

What I learned here, only after reading the manual, is that:

“The Data Loader does not support nested queries or querying child objects. For example, queries similar to the following return an error:

SELECT Amount, Id, Name, (SELECT Quantity, ListPrice,
PriceBookEntry.UnitPrice, PricebookEntry.Name,
PricebookEntry.product2.Family FROM OpportunityLineItems)
FROM Opportunity “

Data Loader does support querying parents. For example, you can query the ID of account records that are the parents of contact records:
"SELECT Id, Account.Id, CreatedById from Contact”

The net effect, is most of the examples the SOQL reference don't work. So still trying to find the perfect environment for testing SOQL.

Posted by choppen5 at 02:53 PM