Deprecated: Optional parameter $list declared before required parameter $is_script is implicitly treated as a required parameter in /home1/oijoiv2f/public_html/wp-content/plugins/apus-framework/libs/redux/ReduxCore/inc/class.redux_cdn.php on line 21

Deprecated: Optional parameter $register declared before required parameter $footer_or_media is implicitly treated as a required parameter in /home1/oijoiv2f/public_html/wp-content/plugins/apus-framework/libs/redux/ReduxCore/inc/class.redux_cdn.php on line 45

Deprecated: Optional parameter $register declared before required parameter $footer_or_media is implicitly treated as a required parameter in /home1/oijoiv2f/public_html/wp-content/plugins/apus-framework/libs/redux/ReduxCore/inc/class.redux_cdn.php on line 104

Deprecated: Optional parameter $expire declared before required parameter $path is implicitly treated as a required parameter in /home1/oijoiv2f/public_html/wp-content/plugins/apus-framework/libs/redux/ReduxCore/inc/class.redux_functions.php on line 54

Deprecated: Optional parameter $depth declared before required parameter $output is implicitly treated as a required parameter in /home1/oijoiv2f/public_html/wp-content/themes/entaro/inc/classes/megamenu.php on line 155

Deprecated: Optional parameter $depth declared before required parameter $output is implicitly treated as a required parameter in /home1/oijoiv2f/public_html/wp-content/themes/entaro/inc/classes/mobilemenu.php on line 147

Deprecated: Optional parameter $args declared before required parameter $wp_customize is implicitly treated as a required parameter in /home1/oijoiv2f/public_html/wp-content/plugins/apus-framework/libs/redux/ReduxCore/inc/extensions/customizer/extension_customizer.php on line 583

Deprecated: Optional parameter $args declared before required parameter $wp_customize is implicitly treated as a required parameter in /home1/oijoiv2f/public_html/wp-content/plugins/apus-framework/libs/redux/ReduxCore/inc/extensions/customizer/extension_customizer.php on line 606

Warning: Cannot modify header information - headers already sent by (output started at /home1/oijoiv2f/public_html/wp-content/plugins/apus-framework/libs/redux/ReduxCore/inc/class.redux_cdn.php:21) in /home1/oijoiv2f/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home1/oijoiv2f/public_html/wp-content/plugins/apus-framework/libs/redux/ReduxCore/inc/class.redux_cdn.php:21) in /home1/oijoiv2f/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home1/oijoiv2f/public_html/wp-content/plugins/apus-framework/libs/redux/ReduxCore/inc/class.redux_cdn.php:21) in /home1/oijoiv2f/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home1/oijoiv2f/public_html/wp-content/plugins/apus-framework/libs/redux/ReduxCore/inc/class.redux_cdn.php:21) in /home1/oijoiv2f/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home1/oijoiv2f/public_html/wp-content/plugins/apus-framework/libs/redux/ReduxCore/inc/class.redux_cdn.php:21) in /home1/oijoiv2f/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home1/oijoiv2f/public_html/wp-content/plugins/apus-framework/libs/redux/ReduxCore/inc/class.redux_cdn.php:21) in /home1/oijoiv2f/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home1/oijoiv2f/public_html/wp-content/plugins/apus-framework/libs/redux/ReduxCore/inc/class.redux_cdn.php:21) in /home1/oijoiv2f/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home1/oijoiv2f/public_html/wp-content/plugins/apus-framework/libs/redux/ReduxCore/inc/class.redux_cdn.php:21) in /home1/oijoiv2f/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1831
{"id":848,"date":"2017-07-27T05:38:11","date_gmt":"2017-07-27T05:38:11","guid":{"rendered":"http:\/\/www.salesforcenextgen.com\/?p=848"},"modified":"2020-12-28T19:45:30","modified_gmt":"2020-12-28T19:45:30","slug":"dmloperationsdetail","status":"publish","type":"post","link":"https:\/\/salesforcenextgen.com\/dmloperationsdetail\/","title":{"rendered":"DML Operations in detail"},"content":{"rendered":"

DML Operations in detail:<\/strong><\/p>\n

Data manipulation language operations mainly consist of insertion of record and committing it to the database, but we can also do following operations.<\/p>\n

    \n
  1. Delete<\/li>\n
  2. Recover(UnDelete)<\/li>\n
  3. Update<\/li>\n
  4. Insert<\/li>\n
  5. Upsert(update and insert in one operation)<\/li>\n
  6. Merge(In case of duplicate Records)<\/li>\n
  7. Converting Leads<\/li>\n<\/ol>\n

    Inserting and updating the records<\/strong><\/p>\n

    Records can be inserted and updated in the database. Records can be created individually or in bulk using the apex collection.<\/p>\n

    For ex: To insert an account just type the below line of code<\/p>\n

    Insert Acc; (Where Acc is an account sObject)<\/p>\n

    Similarly to insert if we want to update a record we write below line of code<\/p>\n

    Update Acc;<\/p>\n

    Inserting Related record, where the relationship is already been established between the objects, they are associated together through a foreign key for example while creating a contact record we can specify its account by providing the account Id which is the foreign key in this scenario.<\/p>\n

    Ex:<\/p>\n

    Account parentContactAcnt = new Account(Name=\u201dAccount for Contact\u201d);<\/p>\n

    Insert parentContactAcnt;\u00a0\u00a0 \/\/\/\/ using the id generated from this account and provide as a foreign key.<\/p>\n

    ID idforForeignKey = parentContactAcnt.Id;<\/p>\n

    Contact newCon = new Contact(<\/p>\n

    Firstname = \u201cTest\u201d;<\/p>\n

    LastName = \u201cContact\u201d;<\/p>\n

    Phone = \u201c111.222.333\u201d;<\/p>\n

    AccountId = idforForeignKey;<\/p>\n

    );<\/p>\n

    Insert newCon;<\/p>\n

    Updating related records, is a bit more tricky then inserting related records and therefore we have to make two separate update call to update the related records. For example if we are updating a contact and we also want to update its account information, then to update account we have to make a separate DML call, see below for more detail :-<\/p>\n

    Ex:<\/p>\n

    Account parentContactAcnt = new Account(Name=\u201dAccount for Contact\u201d);<\/p>\n

    Insert parentContactAcnt;\u00a0\u00a0 \/\/\/\/ using the id generated from this account and provide as a foreign key.<\/p>\n

    ID idforForeignKey = parentContactAcnt.Id;<\/p>\n

    Contact newCon = new Contact(<\/p>\n

    Firstname = \u201cTest\u201d;<\/p>\n

    LastName = \u201cContact\u201d;<\/p>\n

    Phone = \u201c111.222.333\u201d;<\/p>\n

    AccountId = idforForeignKey;<\/p>\n

    );<\/p>\n

    Insert newCon;<\/p>\n

    newCon.Phone = \u201c223.334.445\u201d;<\/p>\n

    newCon.account. Industry =\u00a0‘Technology’;<\/p>\n

    update newCon;<\/p>\n

    update newCon.account;\u00a0\u00a0\u00a0\u00a0 \/\/\/\/ Separate DMl call to update parent record<\/p>\n

    Records can be related to each other using external Id as well, but this relationship has to be defined beforehand to relate any records.<\/p>\n

    Next: Other DML Operations<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"

    DML Operations in detail: Data manipulation language operations mainly consist of insertion of record and committing it to the database, but we can also do following operations.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[72],"tags":[40,61,74,45,75,38,42,55,51,52],"_links":{"self":[{"href":"https:\/\/salesforcenextgen.com\/wp-json\/wp\/v2\/posts\/848"}],"collection":[{"href":"https:\/\/salesforcenextgen.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/salesforcenextgen.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/salesforcenextgen.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/salesforcenextgen.com\/wp-json\/wp\/v2\/comments?post=848"}],"version-history":[{"count":3,"href":"https:\/\/salesforcenextgen.com\/wp-json\/wp\/v2\/posts\/848\/revisions"}],"predecessor-version":[{"id":2215,"href":"https:\/\/salesforcenextgen.com\/wp-json\/wp\/v2\/posts\/848\/revisions\/2215"}],"wp:attachment":[{"href":"https:\/\/salesforcenextgen.com\/wp-json\/wp\/v2\/media?parent=848"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/salesforcenextgen.com\/wp-json\/wp\/v2\/categories?post=848"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/salesforcenextgen.com\/wp-json\/wp\/v2\/tags?post=848"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}