function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
TehNrdTehNrd 

Opps w/ Products using SOQL?

I am essentially trying to replicate an Opportunity with Products report using one SOQL query. I pulled this query from the API documentation, page 339
http://www.salesforce.com/us/developer/docs/api/index.htm (PDF).

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

To test it out I pasted it in the Data Loader but recieve an "Error in query: Malformed query string".

Any ideas? Much thanks.
Mysti, Developer DocumentationMysti, Developer Documentation
I just ran this query using the AJAX toolkit and it worked. Will try Data Loader next.
Mysti, Developer DocumentationMysti, Developer Documentation
It fails for me in export wizard for data loader 11.0--I'm looking for the answer, will post back as soon as I find out what's wrong.
TehNrdTehNrd
Sounds great. Thanks for the help.
Mysti, Developer DocumentationMysti, Developer Documentation
Data Loader does not support nested queries, that's why this fails.
TehNrdTehNrd
Thanks for the insight.

We've got a need to use that type of query to pull data in to a local SQL database and I was curious as to how the headers would be formated. I guess I'll let IT worry about it.

Thanks again.
Mysti, Developer DocumentationMysti, Developer Documentation
If there's any way to construct the query, you can use "dot notation" for reference fields only. For example, Account has a reference field ParentId, so you can execute queries like this:

SELECT id, parent.id from account

Not sure that helps you in this instance, but that's all the info I have right now.