{"id":1507,"date":"2026-09-05T17:00:00","date_gmt":"2026-09-05T11:30:00","guid":{"rendered":"https:\/\/swapnilzambare.com\/blog\/apex-database-class-partial-success\/"},"modified":"2026-09-05T17:00:00","modified_gmt":"2026-09-05T11:30:00","slug":"apex-database-class-partial-success","status":"publish","type":"post","link":"https:\/\/swapnilzambare.com\/blog\/apex-database-class-partial-success\/","title":{"rendered":"Apex Database Class and Partial Success Explained"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The Apex Database Class gives you DML methods with more control than plain DML statements. Its best-known feature is partial success. When you load 200 records and 3 fail, the good 197 still save, and you get a clear list of what went wrong.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this post, you will learn the main Database methods, read SaveResult and Database.Error objects, and use DMLOptions. This builds directly on <a href=\"https:\/\/swapnilzambare.com\/blog\/dml-operations-in-apex\/\">DML operations in Apex<\/a>. It also uses the <a href=\"https:\/\/swapnilzambare.com\/blog\/apex-loops-for-while-do-while\/\">loops<\/a> and <a href=\"https:\/\/swapnilzambare.com\/blog\/apex-collections-list-set-map\/\">collections<\/a> you learned in Level 2.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is the Apex Database Class?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The Apex Database Class is a built-in class with static methods for working with the database. Database.insert, Database.update, Database.upsert, Database.delete and Database.undelete do the same jobs as DML statements. However, they accept an extra allOrNone flag and return result objects for every record.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Think of a teacher collecting 30 homework books. With plain DML, one missing name means she rejects the whole pile. With the Database class, she accepts the 29 good books and returns one with a note saying &#8220;name missing&#8221;. Everyone else&#8217;s work still counts.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why the Apex Database Class Matters<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Real data is messy, especially from integrations and imports. Here is why the Apex Database Class matters at Bright Path Tutors.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>First, the nightly import has 500 enrolments, and a few always fail validation.<\/li>\n\n<li>Also, the business wants the good records saved, not the whole batch lost.<\/li>\n\n<li>Next, the support team needs a list of failed rows with reasons.<\/li>\n\n<li>An integration must know which records were created and which were updated.<\/li>\n\n<li>Finally, some loads must bypass duplicate rules or allow long text to be cut.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">So the Database class turns all-or-nothing saves into controlled, reportable loads.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How the Apex Database Class Works<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The Apex Database Class follows a clear pattern. First, you call a method such as Database.insert with a list and allOrNone set to false. Next, Salesforce tries to save each record. Then valid records are saved, while invalid ones are skipped. After that, the method returns one result per record, in the same order as your list. Finally, your code loops through the results and handles each error.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"640\" src=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-database-class-partial-success-diagram-1-1024x640.png\" alt=\"Apex Database Class diagram showing allOrNone false, save good records, skip bad records and read results\" class=\"wp-image-1505\" srcset=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-database-class-partial-success-diagram-1-1024x640.png 1024w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-database-class-partial-success-diagram-1-300x188.png 300w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-database-class-partial-success-diagram-1-768x480.png 768w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-database-class-partial-success-diagram-1-1536x960.png 1536w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-database-class-partial-success-diagram-1-2048x1280.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">How partial success saves good records and reports bad ones.<\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">The allOrNone Parameter<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">When allOrNone is true, the default, any error fails the whole call, just like plain DML. When it is false, Salesforce saves the good records and reports the bad ones.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Result Objects<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Each method returns its own result type. Insert and update return SaveResult, upsert returns UpsertResult, delete returns DeleteResult and undelete returns UndeleteResult.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Database.Error<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Each failed result holds one or more Database.Error objects. They give the message, the status code and the fields that caused the problem.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">DMLOptions<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Database.DMLOptions sets extra behaviour, such as allowing field truncation or saving despite duplicate rule alerts. You pass it to the method instead of the allOrNone flag.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Access Level<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Database methods can also take AccessLevel.USER_MODE, so the save respects the running user&#8217;s object and field permissions.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Apex Database Class Methods at a Glance<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The table below lists the main methods and their results.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Method<\/th><th>Result type<\/th><th>Useful result methods<\/th><\/tr><\/thead><tbody><tr><td>Database.insert<\/td><td>SaveResult<\/td><td>isSuccess(), getId(), getErrors()<\/td><\/tr><tr><td>Database.update<\/td><td>SaveResult<\/td><td>isSuccess(), getErrors()<\/td><\/tr><tr><td>Database.upsert<\/td><td>UpsertResult<\/td><td>isCreated(), isSuccess()<\/td><\/tr><tr><td>Database.delete<\/td><td>DeleteResult<\/td><td>isSuccess(), getErrors()<\/td><\/tr><tr><td>Database.undelete<\/td><td>UndeleteResult<\/td><td>isSuccess(), getErrors()<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">DML Statements vs the Apex Database Class<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The table below compares plain DML with Database methods.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Feature<\/th><th>DML statement<\/th><th>Database method<\/th><\/tr><\/thead><tbody><tr><td>Partial success<\/td><td>No<\/td><td>Yes, with allOrNone false<\/td><\/tr><tr><td>Error handling<\/td><td>Catch DmlException<\/td><td>Read result objects<\/td><\/tr><tr><td>Returns results per record<\/td><td>No<\/td><td>Yes<\/td><\/tr><tr><td>Extra options<\/td><td>No<\/td><td>DMLOptions and AccessLevel<\/td><\/tr><tr><td>Code length<\/td><td>Shorter<\/td><td>A little longer<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">When to use which depends on the data. Use plain DML when every record must save together. Use the Database class for imports, integrations and any load where partial success is acceptable.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"640\" src=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-database-class-partial-success-diagram-2-1024x640.png\" alt=\"Apex Database Class diagram comparing DML statements and Database methods\" class=\"wp-image-1506\" srcset=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-database-class-partial-success-diagram-2-1024x640.png 1024w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-database-class-partial-success-diagram-2-300x188.png 300w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-database-class-partial-success-diagram-2-768x480.png 768w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-database-class-partial-success-diagram-2-1536x960.png 1536w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-database-class-partial-success-diagram-2-2048x1280.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">DML statement vs Database method.<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">A Real Apex Database Class Example<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s import enrolments at Bright Path Tutors with partial success. One record is missing its course, so it should fail without stopping the others.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: Insert with allOrNone False<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>List&lt;Enrolment__c&gt; rows = new List&lt;Enrolment__c&gt;{\n    new Enrolment__c(Course__c = 'a015g00000AbC12AAB', Status__c = 'Active'),\n    new Enrolment__c(Course__c = null, Status__c = 'Active'),  \/\/ will fail\n    new Enrolment__c(Course__c = 'a015g00000AbC12AAB', Status__c = 'Active')\n};\n\nList&lt;Database.SaveResult&gt; results = Database.insert(rows, false);<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The second record has no course, which breaks a validation rule. Because allOrNone is false, the other two records still save. Use real course Ids from your org when you run this.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2: Read the Results<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>Integer okCount = 0;\nList&lt;String&gt; failures = new List&lt;String&gt;();\n\nfor (Integer i = 0; i &lt; results.size(); i++) {\n    Database.SaveResult sr = results[i];\n    if (sr.isSuccess()) {\n        okCount++;\n    } else {\n        for (Database.Error err : sr.getErrors()) {\n            failures.add('Row ' + (i + 1) + ': ' + err.getStatusCode()\n                + ' - ' + err.getMessage() + ' ' + err.getFields());\n        }\n    }\n}\nSystem.debug('Saved: ' + okCount + ', failed: ' + failures.size());\nSystem.debug(String.join(failures, '\\n'));<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">With the Apex Database Class, results come back in the same order as the input list. So index i tells us which row failed. For each failure, we record the status code, message and fields, ready for an error log or email.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: Read the Output<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Here is an example of the debug log.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>USER_DEBUG [15]|DEBUG|Saved: 2, failed: 1\nUSER_DEBUG [16]|DEBUG|Row 2: FIELD_CUSTOM_VALIDATION_EXCEPTION - Course is required [Course__c]<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Step 4: Upsert and Check What Was Created<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>List&lt;Database.UpsertResult&gt; ur = Database.upsert(coursesFromSystem, Course__c.Course_Code__c, false);\nfor (Database.UpsertResult r : ur) {\n    if (r.isSuccess()) {\n        System.debug(r.getId() + (r.isCreated() ? ' created' : ' updated'));\n    }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Database.upsert takes the external ID field as a field token. Then isCreated tells you whether each record was new or updated, which integrations often need to report.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 5: Use DMLOptions<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>Database.DMLOptions opts = new Database.DMLOptions();\nopts.allowFieldTruncation = true;\nopts.optAllOrNone = false;\n\nDatabase.insert(rows, opts);<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">allowFieldTruncation cuts text that is too long for a field instead of failing. optAllOrNone works like the allOrNone flag.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Partial Success and Triggers<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Partial success in the Apex Database Class has one detail that surprises many developers. When some records fail, Salesforce may roll back and run triggers again for the records that succeed. So triggers should give the same result if they run twice, and they should not send emails or callouts directly.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Common Mistakes with the Apex Database Class<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Calling Database.insert without false, then expecting partial success.<\/li>\n\n<li>Ignoring the result list, so failures go unnoticed.<\/li>\n\n<li>Losing the link between results and input rows by changing list order.<\/li>\n\n<li>Logging only the first error when a record has several.<\/li>\n\n<li>Using partial success where all records must save together.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Best Practices for the Apex Database Class<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use allOrNone false for imports and integrations.<\/li>\n\n<li>Always loop through results and log every failure.<\/li>\n\n<li>Keep the input list order unchanged until you read results.<\/li>\n\n<li>Store errors in a custom log object for support teams.<\/li>\n\n<li>Use AccessLevel.USER_MODE when saves must respect user permissions.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Practice Task<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Write code that updates the fee on ten courses with Database.update and partial success. Then build a map of course Id to error message for the failed rows. Hint: use the input list index to get each failed record&#8217;s Id.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Most Asked Interview Questions on the Apex Database Class<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The Apex Database Class is a very common interview topic, especially for integration roles. Here are the 20 questions asked most.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Basic Questions on the Apex Database Class<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q1: What is the Database class in Apex?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It is a built-in class with methods for DML and queries. Its DML methods can allow partial success and return result objects.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q2: What is partial success?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It means good records save even when some records fail. You get it by passing allOrNone as false.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q3: What is the default value of allOrNone?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">True. So without false, Database methods behave like plain DML.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q4: What does Database.insert return?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A list of Database.SaveResult objects, one per record, in the same order as the input.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q5: What does Database.upsert return?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A list of Database.UpsertResult objects, which also tell you if each record was created or updated.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q6: How do you check if a record saved?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Call isSuccess() on its result. If it is false, read getErrors().<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q7: What information does Database.Error give?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The message, the status code and the fields involved in the error.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Code and Scenario Questions on the Apex Database Class<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q8: How do you find which input row failed?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Use the result index. For example, results[i] matches rows[i], because order is kept.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q9: When would you choose Database.insert over insert?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For imports and integrations, where saving good records and reporting bad ones is better than failing everything.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q10: Does Database.insert throw an exception with allOrNone false?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Not for record errors. Instead, errors appear in the results. However, some system errors can still throw exceptions.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q11: What is Database.DMLOptions?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It is a class that sets extra options, such as allowFieldTruncation, optAllOrNone and duplicate rule settings.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q12: How do you allow saving despite duplicate rules?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Set opts.DuplicateRuleHeader.allowSave = true on DMLOptions, then pass the options to the save.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q13: How do you save in user mode?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Pass AccessLevel.USER_MODE, for example Database.insert(rows, false, AccessLevel.USER_MODE).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q14: How do you know if an upserted record was new?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Call isCreated() on its UpsertResult.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Advanced Questions on the Apex Database Class<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q15: Do triggers run for failed records?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Triggers run during the attempt. However, failed records are not saved, and Salesforce may run triggers again for the successful ones.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q16: Why should triggers be safe to run twice?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Because partial success can re-run them for successful records. So avoid direct emails or counters that double.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q17: Do Database methods count against DML limits?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Yes. Each call counts as one DML statement, and each record counts toward the 10,000 row limit.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q18: How would you report import failures to users?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Collect errors from the results, save them in a log object, and send a summary email or show them in a component.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q19: Can you mix allOrNone false with a savepoint?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Yes. You can set a savepoint, save with partial success, and roll back if too many records fail.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q20: What is the difference between getErrors() and DmlException methods?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">getErrors() reads errors from result objects in partial saves. In contrast, DmlException methods read errors after a failed DML statement.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Official Resources<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/developer.salesforce.com\/docs\/atlas.en-us.apexref.meta\/apexref\/apex_methods_system_database.htm\" target=\"_blank\" rel=\"noopener noreferrer\">Database Class (Apex Reference Guide)<\/a><\/li>\n\n<li><a href=\"https:\/\/developer.salesforce.com\/docs\/atlas.en-us.apexcode.meta\/apexcode\/langCon_apex_dml_database.htm\" target=\"_blank\" rel=\"noopener noreferrer\">DML Statements vs Database Class Methods (Apex Developer Guide)<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Quick Recap<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The Apex Database Class offers DML methods with partial success.<\/li>\n\n<li>Pass allOrNone false to save good records and report bad ones.<\/li>\n\n<li>Results come back in input order as SaveResult, UpsertResult and others.<\/li>\n\n<li>Database.Error gives the message, status code and fields.<\/li>\n\n<li>DMLOptions and AccessLevel add extra control.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">What&#8217;s Next?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Partial success saves what it can. Sometimes you need the opposite: undo a set of changes. Next, read our guide to <a href=\"https:\/\/swapnilzambare.com\/blog\/apex-savepoints-and-rollback\/\">Apex savepoints and rollback<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Apex Database Class gives you DML methods with more control than plain DML statements. Its best-known feature is partial success. When you load&hellip;<\/p>\n","protected":false},"author":1,"featured_media":1504,"comment_status":"","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_swapz_level":"","_swapz_series_part":0,"_swapz_hide_toc":false,"_swapz_hide_featured":false,"_swapz_description":"","footnotes":""},"categories":[8,96],"tags":[98,107,26,91,7,97],"swapz_series":[],"class_list":["post-1507","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-salesforce","category-salesforce-developer","tag-apex","tag-dml","tag-intermediate","tag-interview-questions","tag-salesforce","tag-salesforce-developer"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Apex Database Class and Partial Success Guide<\/title>\n<meta name=\"description\" content=\"Apex Database Class explained simply: Database.insert with allOrNone false, SaveResult, Database.Error, DMLOptions, user mode and 20 interview Q&amp;A.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/swapnilzambare.com\/blog\/apex-database-class-partial-success\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Apex Database Class and Partial Success Guide\" \/>\n<meta property=\"og:description\" content=\"Apex Database Class explained simply: Database.insert with allOrNone false, SaveResult, Database.Error, DMLOptions, user mode and 20 interview Q&amp;A.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/swapnilzambare.com\/blog\/apex-database-class-partial-success\/\" \/>\n<meta property=\"og:site_name\" content=\"Swapnil Zambare - Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-05T11:30:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-database-class-partial-success-featured.png\" \/>\n\t<meta property=\"og:image:width\" content=\"2400\" \/>\n\t<meta property=\"og:image:height\" content=\"1260\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Swapnil Zambare\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Swapnil Zambare\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-database-class-partial-success\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-database-class-partial-success\\\/\"},\"author\":{\"name\":\"Swapnil Zambare\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#\\\/schema\\\/person\\\/922ac0131aaa7088c78c2cb1700e0c9a\"},\"headline\":\"Apex Database Class and Partial Success Explained\",\"datePublished\":\"2026-09-05T11:30:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-database-class-partial-success\\\/\"},\"wordCount\":1655,\"publisher\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-database-class-partial-success\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/apex-database-class-partial-success-featured.png\",\"keywords\":[\"Apex\",\"DML\",\"Intermediate\",\"Interview Questions\",\"Salesforce\",\"Salesforce Developer\"],\"articleSection\":[\"Salesforce\",\"Salesforce Developer\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-database-class-partial-success\\\/\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-database-class-partial-success\\\/\",\"name\":\"Apex Database Class and Partial Success Guide\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-database-class-partial-success\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-database-class-partial-success\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/apex-database-class-partial-success-featured.png\",\"datePublished\":\"2026-09-05T11:30:00+00:00\",\"description\":\"Apex Database Class explained simply: Database.insert with allOrNone false, SaveResult, Database.Error, DMLOptions, user mode and 20 interview Q&A.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-database-class-partial-success\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-database-class-partial-success\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-database-class-partial-success\\\/#primaryimage\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/apex-database-class-partial-success-featured.png\",\"contentUrl\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/apex-database-class-partial-success-featured.png\",\"width\":2400,\"height\":1260,\"caption\":\"Apex Database Class featured image: title card with an Apex code example\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/apex-database-class-partial-success\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Apex Database Class and Partial Success Explained\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/\",\"name\":\"Swapnil Zambare - Blog\",\"description\":\"Salesforce &amp; Tech Guides\",\"publisher\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#organization\",\"name\":\"Swapnil Zambare - Blog\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/site-icon-512.png\",\"contentUrl\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/site-icon-512.png\",\"width\":512,\"height\":512,\"caption\":\"Swapnil Zambare - Blog\"},\"image\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/theSwapnilZambare\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#\\\/schema\\\/person\\\/922ac0131aaa7088c78c2cb1700e0c9a\",\"name\":\"Swapnil Zambare\",\"sameAs\":[\"https:\\\/\\\/swapnilzambare.com\\\/blog\"],\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/author\\\/swapnil-zambare\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Apex Database Class and Partial Success Guide","description":"Apex Database Class explained simply: Database.insert with allOrNone false, SaveResult, Database.Error, DMLOptions, user mode and 20 interview Q&A.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/swapnilzambare.com\/blog\/apex-database-class-partial-success\/","og_locale":"en_US","og_type":"article","og_title":"Apex Database Class and Partial Success Guide","og_description":"Apex Database Class explained simply: Database.insert with allOrNone false, SaveResult, Database.Error, DMLOptions, user mode and 20 interview Q&A.","og_url":"https:\/\/swapnilzambare.com\/blog\/apex-database-class-partial-success\/","og_site_name":"Swapnil Zambare - Blog","article_published_time":"2026-09-05T11:30:00+00:00","og_image":[{"width":2400,"height":1260,"url":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-database-class-partial-success-featured.png","type":"image\/png"}],"author":"Swapnil Zambare","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Swapnil Zambare","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/swapnilzambare.com\/blog\/apex-database-class-partial-success\/#article","isPartOf":{"@id":"https:\/\/swapnilzambare.com\/blog\/apex-database-class-partial-success\/"},"author":{"name":"Swapnil Zambare","@id":"https:\/\/swapnilzambare.com\/blog\/#\/schema\/person\/922ac0131aaa7088c78c2cb1700e0c9a"},"headline":"Apex Database Class and Partial Success Explained","datePublished":"2026-09-05T11:30:00+00:00","mainEntityOfPage":{"@id":"https:\/\/swapnilzambare.com\/blog\/apex-database-class-partial-success\/"},"wordCount":1655,"publisher":{"@id":"https:\/\/swapnilzambare.com\/blog\/#organization"},"image":{"@id":"https:\/\/swapnilzambare.com\/blog\/apex-database-class-partial-success\/#primaryimage"},"thumbnailUrl":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-database-class-partial-success-featured.png","keywords":["Apex","DML","Intermediate","Interview Questions","Salesforce","Salesforce Developer"],"articleSection":["Salesforce","Salesforce Developer"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/swapnilzambare.com\/blog\/apex-database-class-partial-success\/","url":"https:\/\/swapnilzambare.com\/blog\/apex-database-class-partial-success\/","name":"Apex Database Class and Partial Success Guide","isPartOf":{"@id":"https:\/\/swapnilzambare.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/swapnilzambare.com\/blog\/apex-database-class-partial-success\/#primaryimage"},"image":{"@id":"https:\/\/swapnilzambare.com\/blog\/apex-database-class-partial-success\/#primaryimage"},"thumbnailUrl":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-database-class-partial-success-featured.png","datePublished":"2026-09-05T11:30:00+00:00","description":"Apex Database Class explained simply: Database.insert with allOrNone false, SaveResult, Database.Error, DMLOptions, user mode and 20 interview Q&A.","breadcrumb":{"@id":"https:\/\/swapnilzambare.com\/blog\/apex-database-class-partial-success\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/swapnilzambare.com\/blog\/apex-database-class-partial-success\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/swapnilzambare.com\/blog\/apex-database-class-partial-success\/#primaryimage","url":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-database-class-partial-success-featured.png","contentUrl":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/apex-database-class-partial-success-featured.png","width":2400,"height":1260,"caption":"Apex Database Class featured image: title card with an Apex code example"},{"@type":"BreadcrumbList","@id":"https:\/\/swapnilzambare.com\/blog\/apex-database-class-partial-success\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/swapnilzambare.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Apex Database Class and Partial Success Explained"}]},{"@type":"WebSite","@id":"https:\/\/swapnilzambare.com\/blog\/#website","url":"https:\/\/swapnilzambare.com\/blog\/","name":"Swapnil Zambare - Blog","description":"Salesforce &amp; Tech Guides","publisher":{"@id":"https:\/\/swapnilzambare.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/swapnilzambare.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/swapnilzambare.com\/blog\/#organization","name":"Swapnil Zambare - Blog","url":"https:\/\/swapnilzambare.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/swapnilzambare.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/09\/site-icon-512.png","contentUrl":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/09\/site-icon-512.png","width":512,"height":512,"caption":"Swapnil Zambare - Blog"},"image":{"@id":"https:\/\/swapnilzambare.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.linkedin.com\/in\/theSwapnilZambare"]},{"@type":"Person","@id":"https:\/\/swapnilzambare.com\/blog\/#\/schema\/person\/922ac0131aaa7088c78c2cb1700e0c9a","name":"Swapnil Zambare","sameAs":["https:\/\/swapnilzambare.com\/blog"],"url":"https:\/\/swapnilzambare.com\/blog\/author\/swapnil-zambare\/"}]}},"_links":{"self":[{"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/posts\/1507","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/comments?post=1507"}],"version-history":[{"count":0,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/posts\/1507\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/media\/1504"}],"wp:attachment":[{"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/media?parent=1507"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/categories?post=1507"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/tags?post=1507"},{"taxonomy":"swapz_series","embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/swapz_series?post=1507"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}