Bind an Account name
A bind variable puts an Apex value into SOQL with :variable.
Your task
Find the Account whose name has an apostrophe, then show that a bound missing name returns zero rows.
String tag = 'AS-Q304-' + UserInfo.getUserId() + '-' +
String.valueOf(Datetime.now().getTime());
String wantedName = tag + '-O\'Brien';
List<Account> seeded = new List<Account>{
new Account(Name = wantedName),
new Account(Name = tag + '-Decoy')
};
insert seeded;
Integer foundCount = -1;
Integer missingCount = -1;
System.debug('Bind found: ' + foundCount);
System.debug('Bind quote safe: false');
System.debug('Bind missing: ' + missingCount);
System.debug('Bind decoy excluded: false');Requirements
Database.query(should be absentName = :wantedNameshould be present- A second
Name = :<variable>should be present Bind found: 1should be printedBind quote safe: trueshould be printedBind missing: 0should be printedBind decoy excluded: trueshould be printed