- 
                Notifications
    
You must be signed in to change notification settings  - Fork 0
 
The Soql.Binder Class
        Jason Siders edited this page Jul 4, 2025 
        ·
        4 revisions
      
    Registers a bind variable to be used in the query. Ex, SELECT Id FROM Account WHERE Name = :foo.
Use this method in conjunction with the addWhere and addBind SOQL methods.
Soql.Binder profileName = new Soql.Binder('profileName', 'System Administrator');
Soql.Binder userId = new Soql.Binder('userId', UserInfo.getUserId());
Soql query = DatabaseLayer.Soql.newQuery(User.SObjectType)
  ?.addWhere(User.Id, Soql.NOT_EQUALS, userId)
  ?.addWhere(new Soql.ParentField(User.ProfileId, Profile.Name), Soql.EQUALS, profileName)
  ?.toSoql();💡 Tip: When a child query (Soql.InnerQuery or Soql.Subquery) with binds is added to a parent Soql query, the parent query inherits its bind keys/values.
Soql.Binder owner = new Soql.Binder('ownerId', UserInfo.getUserId());
Soql.Subquery subquery = new Soql.Subquery(Opportunity.AccountId)
  ?.addWhere(Opportunity.OwnerId, Soql.EQUALS, owner)
  ?.toSubquery();
// No need to explicitly bind the 'owner' to the parent query:
Soql query = DatabaseLayer.Soql.newQuery(Account.SObjectType)
  ?.addSelect(subquery)
  ?.toSoql();Soql.Binder(String key, Object value)Soql.Binder(String key)
Returns the name of the bind variable to be used in the query.
String getKey()
Returns the underlying value to be substituted at runtime during the query.
Object getValue()
Set the underlying value to be substituted for the bind variable. This is done at runtime, when the query is actually made, via the Database.queryWithBinds() method.
Soql.Binder setValue(Object value)
- Generating Test Records
 - Dml
 - Soql
 - Cmdt
 - Plugins
 
- DatabaseLayer
 - Dml
 - MockDml
 - MockRecord
 - Cmdt
 - MockCmdt
 - MockSoql
 - 
Soql
- Soql.AggregateResult
 - Soql.Aggregation
 - Soql.Binder
 - Soql.Builder
 - Soql.Condition
 - Soql.ConditionalLogic
 - Soql.Criteria
 - Soql.Cursor
 - Soql.Function
 - Soql.InnerQuery
 - Soql.InvalidParameterValueException
 - Soql.LogicType
 - Soql.NullOrder
 - Soql.Operation
 - Soql.Operator
 - Soql.ParentField
 - Soql.PreAndPostProcessor
 - Soql.QueryLocator
 - Soql.Request
 - Soql.Scope
 - Soql.Selectable
 - Soql.SortDirection
 - Soql.SortOrder
 - Soql.Subquery
 - Soql.TypeOf
 - Soql.Usage
 - Soql.WhenClause