In Chapter 4, you learned about bind variables. They are variables whose values are injected into SOQL and SOSL statements in predefined locations, notated with colons. But bind variables are not powerful enough to support an entirely dynamic
WHERE clause, one that includes conditional filters added and subtracted based on the behavior of the program. You could write every combination of
WHERE clause and use long strings of conditional statements to pick the right one. An alternative is a completely dynamic query, executed using the
Listing 5.28 provides an example of two dynamic queries. The first is on the Contact object. The results of the query are returned in a list of Contact records. Other ...