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
nitsnits 

between(X,Y) not working in SOQL

opp=[select account.fax, apptaker__c, name, ownerid  from opportunity where apptaker__c=:adid and stagename='Prospecting'and closedate between(frmdt, todt) order by closedate asc];
 
 
I am trying to use this query. I am getting error at between. If apex doesnot support this, what is work around
 
 
Thank in advance.
werewolfwerewolf
What in the docs gave you the impression that "between" was a supported keyword in SOQL?  It isn't.

Try "where closedate >= :fromDate and closedate <= :toDate"
Ad_InfosysAd_Infosys

Thanks for your reply dear!!

It is not mentioned anywhere that SOQL supports between().

now One more query..

if SOQL is like

opp=[select account.fax, apptaker__c, name, ownerid  from opportunity where apptaker__c=:adid and stagename='Prospecting' order by name asc];

now here if you see order by name. this work fine as name is field in opportunity.
 
but if I try
 
string x='name';
opp=[select account.fax, apptaker__c, name, ownerid  from opportunity where apptaker__c=:adid and stagename='Prospecting' order by :x asc];
 
This throws error.
 
Kinldy suggest some resolution
SuperfellSuperfell
Just like SQL, the binding operator (: in apex) is for values, not for field/table names.
Ad_InfosysAd_Infosys
So if you can suggest work around.
SuperfellSuperfell
there's no good workaround, you can wait for dynamic soql in apex, or if ultimately your apex code is being run from a webservice, you could build the apex dynamically in the client and use execute anonymous. if your code is being run from a trigger or VF, then i don't think there is a workaround.
Ad_InfosysAd_Infosys

The web service will be called by a UI developed in java.

SO how execute anonymous can help our cause

.
 
One Major query Simon,
 
How many concurrent callouts can be made to a web service in SFDC from external application.
Is there any limit on the number of sessions that can be established.
SuperfellSuperfell
executeAnonymous allows you to pass a block of apex code to the server for it to execute. so you can dynamically build the query as part of that code on the client before executing it. although right now i can't remember if you can get any data back from execAnon, so it would depend on the details. Of course you could just do your query through the regular API and skip apex alltogether.