Apex Data Manipulation (DML) Operations
  • Share this blog:

Apex Data Manipulation Language(DML) Operations in Salesforce

 Use Data Manipulation Language (DML) Operations to insert, update, delete, and restore data in a database.We can execute DML Operations using two different forms.

  1. Apex DML Statement, Such as

Insert SObject();

  1. Apex DML database methods, such as

Database.saversult() result=Data Insert(SObject()); --->The following example that inserts a new invoice statement by calling insert and if we execute in the 'Developer console" that creates a record into the database. Invoice_Statements_c Inv=new Invoice_statement_c(Description)c='capital info solutions'); Insert Inv ---> Inserting the invoice using DML. Note:- After the invoice statement is inserted the sobject variable inv will contain the ID of the new invoice statement. * The following example shows the creating records through API for Account object using Insert DML Operation.

Account a=new Account();
 a.Name='Osmania University';

Insert a;---> this means assigning the field values to account record

Enthusiastic about exploring the skill set of Salesforce? Then, have a look at the Salesforce Training together additional knowledge.

DML Operation used for inserting a record----> The following example shows the creating a contact through API using DML operation (Insert)

Contact C= new contact();
 C.last name='Anil';
 C.Account id='XXX'

Override any account id here //This means assigning account to a contact

Insert C;

Note:- For custom Objects;

Customer_c C=new customer_c();

API Name of lookup filed or MD field Insert c; Customer__c is child object and partner__c is parent object Note: while inserting the object records the following notes

  • Certain SObjects cannot be created to insert an object record because the ”create” permission of the object must be set to true
  • We must supply a non-null value for all required fields
  • The “insert” statement automatically sets the ID value of all new subjects records
  • We can pass a maximum of 10,000 SObject records by using a single insert method.

For indepth understanding of Salesforce click on

You liked the article?

Like : 0

Vote for difficulty

Current difficulty (Avg): Medium

Recommended Courses


About Author
Author Bio

TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills in the market.

Stay Updated

Get stories of change makers and innovators from the startup ecosystem in your inbox