This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String idInClause = '(\''; | |
for (Id acctId : accountIds){ | |
idInClause += acctId + ‘\’,\’’; | |
} | |
idInClause = idInClause.substring(0,idInClause.length()-2); | |
idInClause += ')'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Set<Id> accountIds = … | |
/* The accountIds variable is directly embedded in the accountQuery string and binded | |
against in Database.query | |
*/ | |
String accountQuery = ‘select id, name from Account where Id in :accountIds’; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String accountQuery = ‘Select id, name from Account where Id in :getAccountids()’; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Account acct = new Account(Id = ‘Some_Acct_Id_Here’); | |
String accountQuery = ‘Select id, name from Account where Id = :acct.Id’; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Valid Dynamic SOQL from function | |
Set<Id> accountIds = getAccountids(); | |
String accountQuery = ‘Select id, name from Account where Id in :accountIds’; | |
// Valid Dynamic SOQL from SObject | |
Account acct = new Account(Id = ‘Some_Acct_Id_Here’); | |
Id accountId = acct.Id; | |
String accountQuery = ‘Select id, name from Account where Id = :accountId’; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @description Builder class for dealing with Account records. | |
* Solely used for testing, NOT a data factory. | |
**/ | |
@isTest | |
public class AccountTestData extends SObjectTestData { | |
/** | |
* @description Overridden method to set up the default | |
* Account state for AccountTestData. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String format = 'Select Id from Account where Id = \'{0}\''; | |
String Id = '<some_id>'; | |
String query = String.format(format, new List<String>{ Id }); | |
system.debug(' query is ' + query); | |
// Output: query is Select Id from Account where Id = {0} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String format = 'Select Id from Account where Id = {0}'; | |
String Id = '<some_id>'; | |
String query = String.format(format, new List<String>{ Id }); | |
system.debug(' query is ' + query); | |
// Output: query is Select Id from Account where Id = <some_id> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String format = 'Select Id from Account where Id = \'\'{0}\'\''; | |
String Id = '<some_id>'; | |
String query = String.format(format, new List<String>{ Id }); | |
system.debug(' query is ' + query); | |
// Output: query is Select Id from Account where Id = '<some_id>' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static List<Database.UpsertResult> upsertListSObjectsWithExternalIdNoAllOrNothingErrorExample() { | |
List<SObject> records = new List<SObject>(); | |
Account a = new Account( | |
Name = 'Example Company', | |
External_Id__c = 'ExampleCompany' | |
); | |
records.add(a); | |
OlderNewer