You need to sign in to do that
Don't have an account?

Adding space in Dynamic SOQL
Hi ,
Can some one please to add the space before FROM in Dynamic SOQL.
string query ='SELECT ' + qFields +
'FROM contact'+
' WHERE user_num__c = \'' + String.escapeSingleQuotes(uNum) + '\''+
' LIMIT 1';
Can some one please to add the space before FROM in Dynamic SOQL.
string query ='SELECT ' + qFields +
'FROM contact'+
' WHERE user_num__c = \'' + String.escapeSingleQuotes(uNum) + '\''+
' LIMIT 1';
As an example, if the qFields variable is null or an empty string in production then your query would be 'SELECT FROM...' which would cause the error you're seeing.
All Answers
FYi..Im getting the error while deploying the changes in production...
ERROR:: System.QueryException: unexpected token: 'FROM'
Printed query from sandbox..(170233661)|USER_DEBUG|[44]|INFO|query#SELECT TRA_Given__c, Receive_Customer_Feedback_By_Email__c, Receive_Market_Summary_By_Email__c, Evening_Phone_RK_Provided__c, FirstName, Foreign_Resident__c, Gender__c, HomePhone, Investment_Objective__c FROM contact WHERE user_num__c = '22494878' LIMIT 1
thanks
shashi
As an example, if the qFields variable is null or an empty string in production then your query would be 'SELECT FROM...' which would cause the error you're seeing.
Same changeset i was able to deploy in a different sandbox but failing in production.