You need to sign in to do that
Don't have an account?
andremsalgado
SOQL structure issues, variables comparison
Hello Folks,
Actually this is more than a doubt than a discussion...
I've been working with Salesforce Development more than 03 years and I never get why to use ":" to do variables comparison, like the following :
Sample 1:
Sample 2:
Could anyone explain me why? And Kill my curiosity?
Wish all the best! Thank you in advance!
Actually this is more than a doubt than a discussion...
I've been working with Salesforce Development more than 03 years and I never get why to use ":" to do variables comparison, like the following :
Sample 1:
List<AnyObject__c> objC = [Select id FROM AnyObject__c WHERE year__c = '1994'];
Sample 2:
String yearSample = '1994'; List<AnyObject__c> objC = [Select id FROM AnyObject__c WHERE year__c =: yearSample];Yes, I know the both Samples Work and I'm already accustomed to write this way... But it does really grinds my gears!!
Could anyone explain me why? And Kill my curiosity?
Wish all the best! Thank you in advance!
in Sample 2, you are setting the filter for your SOQL at runtime and by giving a : you tell sfdc to pick value from a variable
Ta
Vish
All Answers
in Sample 2, you are setting the filter for your SOQL at runtime and by giving a : you tell sfdc to pick value from a variable
Ta
Vish
Thanks for your response, so in fact I need to use the ":" cuz it's necessary for the platform compile my code?
I never found the documentation for this issue!
Regards!