Back

DML, SOQL and SOSL Interview Q&A

1. What are the DML statements available in Apex?
  • Insert
  • Update
  • Delete
  • Undelete
  • Upsert (Combination of insert and update)
  • Merge (Combination of update and delete)
2. What is Governor Limits for DML statements?

Number of DML statements per transaction: 150 (as a whole including insert, update, delete and undelete)

Number of rows processed per DML statement: 10000

3.What is SOQL?

SOQL: Salesforce Object Query Language

SOQL Purpose: To fetch records from an object and related objects.

We can write query on one object while querying on those objects we can fetch the child object records or parent object records

Governor Limits for SOQL statements

SOQL queries per transaction: 100

SOQL query rows returned: 50000

4. What is SOSL?

SOSL: Salesforce Object Search Language

SOSL Purpose: We can search for a value in multiple objects (no need of any relationship).

Results of SOSL query can be stored in List<List>.

Governor Limits for SOSL statements:

SOSL queries per transaction: 20

SOSL query rows returned: 2000

5.Difference between insert/update and Database.insert/ Database.update?

Assume that you are inserting 100 records.

Insert / Update Database.Insert
If any one of the record fail due to error then entire operation will fail. None of the records will be saved into the database, by using insert/update if we use try-catch then we can capture only one error which will cause to stop the operation. If any one of the record fail due to error then it will perform partial operation (valid records will be inserted/updated) by using Database.insert(list, false)/ Database.update(list, false)
We can capture all the errors by saving result in Database.saveResult[].
6.There is a Queue with name MyQueue. How to query it using SOQL query from the database?

Queues will store in Group object. To query for MyQueue from the database using SOQL, we should use the following syntax – Group grp = [select Id, Name from Group where Name = ‘MyQueue’ and Type = ‘Queue’ Limit 1];



Back
Site developed by Nikhil Karkra © 2023 | Icons made by Freepik