• gpervukhin
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies

Hi, everybody. I want to share my thoughts with you about the problem that I met with SOQL parser.

 

Here is the query that I tried to execute:

database.query('SELECT Id FROM Task WHERE ((AccountId IN (SELECT Id FROM Account WHERE Name like \'%test%\')) AND (ReminderDateTime > 2013-03-01T00:00:00Z)) AND (Status != \'Completed\')');

 

as a result I've got the following exception:

System.QueryException: Semi join sub-selects are only allowed at the top level WHERE expressions and not in nested WHERE expressions.

 

Let's analyze the query:

C1 = AccountId IN (SELECT Id FROM Account WHERE Name like \'%test%\')

C2 = ReminderDateTime > 2013-03-01T00:00:00Z

C3 = Status != \'Completed\'

 

Result:

... Where ((C1) AND (C2)) AND (C3)

 

 

Let's do another similar test. Everything works, if I reorganize the query in this way:

database.query('SELECT Id FROM Task WHERE (AccountId IN (SELECT Id FROM Account WHERE Name like \'%test%\')) AND (ReminderDateTime > 2013-03-01T00:00:00Z) AND (Status != \'Completed\')');

 

Analysis:

... Where (C1) AND (C2) AND (C3)

 

 

So, I can't see a real problem in the first query.

 

p.s.1: I do not exclude that this could be my error.

p.s.2: I will be very grateful for your answers, but please do not suggest to remove brackets, because this query is generated in code, and please suggest me to reorganize the query only if it's really incorrect.

Are there plans in the road map to allow custom fields on the OpportunityLineItemSchedule object?

In my case, a client would like to add another Quantity-type (double) field onto the OpportunityLineItemSchedule object.

Thanks.