You need to sign in to do that
Don't have an account?
query using wildcard/bind varibale
Hey..I am kinda new to Salesforce/apex/visualforce. Plz help me resolve the following issue.
for(TP_TPM_DEAL_TYPE_TBL__c dea:(Database.query('Select DEAL_TYPE__c,DEAL_TYPE_NAME__c From TP_TPM_DEAL_TYPE_TBL__c where DEAL_TYPE__c like :(SearchCriteria.DEAL_TYPE__c+'%') order by ' + sortFullExp + ' limit 1000'))){
wrapList.add(New wrapperclass(dea,false));
}
error messgae:
Save error: line 53:174 no viable alternative at character '%'
What is the difference between using database.query and using a query directly in []?
Any help is greatly appreciated!Thanks in advance!
You have to create the wildcard string outside of the SOQL query and bind that in, otherwise it has no effect even if there is no syntax error:
All Answers
You have to create the wildcard string outside of the SOQL query and bind that in, otherwise it has no effect even if there is no syntax error:
Sorry to bother you. But now i am getting another error.
Attempt to de-reference a null object
I have used an input field to input the data in the page
<apex:inputField value="{! SearchCriteria.DEAL_TYPE__c}"/>
And has used a getter/setter in the controller
public TP_TPM_DEAL_TYPE_TBL__c SearchCriteria{get;set;}
Have you created an instance of the record to store the results in?
If not, you'll need the following in your constructor:
My bad. I had conveniently forgot that.Thanks a lot for your help!!!!