52,686 views
8 votes
8 votes
Given the following block of code:try{List retrieveRecords = [SELECT Id FROM Account where webSite=null] }catch(Exception e){ {//manage exception logic}What should a developer do to ensure the code execution is disrupted if the retrievedRecordsList remains empty after the SOQL query?A. Check the state of the retrievedRecords variable and throw custom eexception if the veriable is emptyB. Check the state of the retrievedRecords variable and use System.assert(false) if the variable is emptyC. Check the state of the retrievedRecords variable and access the first element of te list if the variable is emptyD. Replace the retrievedRecords variable declaration from a List of Account to a single Account

User Infroz
by
2.7k points

1 Answer

15 votes
15 votes

Answer:

B. Check the state of retrieved records variable and use system.assert false if the variable is empty.

Step-by-step explanation:

SOQL query or Salesforce Object Query Language is used to read information stored in organizations data base. This can be written and executed in Developer Console query editor.

User Tadeu Marques
by
2.5k points