• Andy Rouse 7
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies
I've got a dynamic SOQL query on a search page in Visualforce. One of the inputs is a string field that allows the user to search for records with a particular name. Oddly, particular input strings have produced the following ORA Error:

"common.exception.SfdcSqlException: ORA-01424: missing or illegal character following the escape character"

These strings work fine: "Example" "O'Jones" "O'Keefe" (I was testing names with an inverted comma in them)
This string doesn't: "An'dy" (I was testing my name with an inverted comma randomly inserted"

Does anybody know why the inverted comma would only break the query in certain circumstances? I've used the "EscapeSingleQuotes" method.

Here is a simplified version of the code, in case that helps:
public with sharing class SFBugRecreation {

	public Contact con;
	public string strSearchKeyword {get;set;}
	public string sortDirection {get;set;}
	
	public list<Services__c> lstSearchResult{
    	get;
    	set;
    } 
    	    
    // Standard controller constructor.
    public SFBugRecreation(ApexPages.StandardController pController) {
        con = (Contact) pController.getRecord(); 
    }
    
   //Clear previous search result, button handler
    public PageReference ClearResult()
    {
        strSearchKeyword='';
        lstSearchResult = null;
        return null;
    }
    
    //Search records. Invoked from button click or actionfunction on VF.
    public PageReference doSearch()
    {
        lstSearchResult = new list<Services__c>();
        
		string keywordSearch = '';
        if(strSearchKeyword != null && strSearchKeyword != ''){
        	string strSrcKeyword = string.escapeSingleQuotes('%' + strSearchKeyword.replaceAll('\\*','') + '%');
        	keywordSearch = 'Name like :strSrcKeyword';
        }
        
        string queryStart = 'Select Name from Services__c where ';
    	string queryEnd = keywordSearch+' order by Name ASC LIMIT 200';
        
        lstSearchResult = database.query(queryStart+queryEnd);
        
        return null;
    }

}
<apex:page standardController="Contact" extensions="SFBugRecreation">
	<apex:form >
		<apex:pageblock >
			<apex:inputtext value="{!strSearchKeyword}"/>
			<apex:commandButton value="Search" action="{!doSearch}" status="searchWait" rerender="pbtSearchResult"/>
			<apex:commandButton value="Clear" action="{!ClearResult}" status="searchWait" />
			<apex:actionStatus id="searchWait" startText="Please wait.." />
			
			<apex:outputpanel layout="none" id="pbtSearchResult">
				<apex:pageBlockTable value="{!lstSearchResult}" var="a"  >
					<apex:column headerValue="Service">
			        	<apex:outputField value="{!a.Name}"/> 
					</apex:column>  
				</apex:pageBlockTable>
			</apex:outputpanel>
	</apex:pageblock>
	
	</apex:form>
</apex:page>
I tried opening a case with Salesforce Support, saying it was a bug report (we don't have developer support, so I explicitly stated that I only wanted confirmation that it's a bug), but they closed the case without even looking at it.

Andy

 
Hi all

I am using <lightning:navigation>component and page reference to navigate the user from one component to another component. Basically I am displaying a list of items in first component and the detail in second component. Now if I click on first item, it navigates to second component and displays the details. It works fine for the first time. When the user clicks the another item the second time, the detail of first item is displayed as the second component's INIT METHOD NOT EXECUTED. 

Did anyone has faced similar issue? Please let me know if you have any solution.

Thanks
I've got a dynamic SOQL query on a search page in Visualforce. One of the inputs is a string field that allows the user to search for records with a particular name. Oddly, particular input strings have produced the following ORA Error:

"common.exception.SfdcSqlException: ORA-01424: missing or illegal character following the escape character"

These strings work fine: "Example" "O'Jones" "O'Keefe" (I was testing names with an inverted comma in them)
This string doesn't: "An'dy" (I was testing my name with an inverted comma randomly inserted"

Does anybody know why the inverted comma would only break the query in certain circumstances? I've used the "EscapeSingleQuotes" method.

Here is a simplified version of the code, in case that helps:
public with sharing class SFBugRecreation {

	public Contact con;
	public string strSearchKeyword {get;set;}
	public string sortDirection {get;set;}
	
	public list<Services__c> lstSearchResult{
    	get;
    	set;
    } 
    	    
    // Standard controller constructor.
    public SFBugRecreation(ApexPages.StandardController pController) {
        con = (Contact) pController.getRecord(); 
    }
    
   //Clear previous search result, button handler
    public PageReference ClearResult()
    {
        strSearchKeyword='';
        lstSearchResult = null;
        return null;
    }
    
    //Search records. Invoked from button click or actionfunction on VF.
    public PageReference doSearch()
    {
        lstSearchResult = new list<Services__c>();
        
		string keywordSearch = '';
        if(strSearchKeyword != null && strSearchKeyword != ''){
        	string strSrcKeyword = string.escapeSingleQuotes('%' + strSearchKeyword.replaceAll('\\*','') + '%');
        	keywordSearch = 'Name like :strSrcKeyword';
        }
        
        string queryStart = 'Select Name from Services__c where ';
    	string queryEnd = keywordSearch+' order by Name ASC LIMIT 200';
        
        lstSearchResult = database.query(queryStart+queryEnd);
        
        return null;
    }

}
<apex:page standardController="Contact" extensions="SFBugRecreation">
	<apex:form >
		<apex:pageblock >
			<apex:inputtext value="{!strSearchKeyword}"/>
			<apex:commandButton value="Search" action="{!doSearch}" status="searchWait" rerender="pbtSearchResult"/>
			<apex:commandButton value="Clear" action="{!ClearResult}" status="searchWait" />
			<apex:actionStatus id="searchWait" startText="Please wait.." />
			
			<apex:outputpanel layout="none" id="pbtSearchResult">
				<apex:pageBlockTable value="{!lstSearchResult}" var="a"  >
					<apex:column headerValue="Service">
			        	<apex:outputField value="{!a.Name}"/> 
					</apex:column>  
				</apex:pageBlockTable>
			</apex:outputpanel>
	</apex:pageblock>
	
	</apex:form>
</apex:page>
I tried opening a case with Salesforce Support, saying it was a bug report (we don't have developer support, so I explicitly stated that I only wanted confirmation that it's a bug), but they closed the case without even looking at it.

Andy