on most of our pages, we have some url parameters. we use these parameters as bind variables in various SOQL queries. is there a common pattern we can use which takes care of security issues.
Using bind variables automatically takes care of all SOQL injection vulnerabilities, with no extra effort on the part of the developer. You should always use bind variables on any untrusted or unsanitized user input. You can even use simple bind variables on dynamic queries to avoid having to manually escape special characters.
You can't evaluate Apex Code in dynamic queries, though, so that means you can't use something like:
You can reference a set or list, but you can't reference a single element in a list, for example. If you need to use page parameters from a Visualforce page, for example, you'll have to pull them out into individual variables that you can reference, if you're using dynamic queries.
For inline queries, you can inline complex code if you desire:
|
|||||||||
|