Skip to content

PROC_ExecuteDML

Class · Group: Bulk DML

apex
global inherited sharing class PROC_ExecuteDML implements IF_Async.Processable

Implements: IF_Async.Processable

Known Derived Types: IF_Async.Processable.execute(List<Object>)

Processor for generic DML operations using the adaptive async framework. Implements IF_Async.Processable to enable automatic selection between Queueable and Batch execution. Supports INSERT, UPDATE, DELETE, UPSERT, and UNDELETE operations.

Since: 1.0

Example:

apex
PROC_ExecuteDML processor = new PROC_ExecuteDML(DML_Builder.DatabaseOperation.DML_UPDATE, false);
UTIL_AsynchronousJobLauncher.process(
    new UTIL_AsynchronousJobLauncher.DTO_AsynchronousJobRequest(queryable), processor
);

See Also: IF_Async.Processable, UTIL_AsynchronousJobLauncher


Methods

MethodDescription
global void execute(List<Object> items)Executes the configured DML operation on the provided list of records.
global PROC_ExecuteDML(DML_Builder.DatabaseOperation operation)Constructs a DML processor with the specified operation and default all-or-nothing behavior.
global PROC_ExecuteDML(DML_Builder.DatabaseOperation operation, Boolean allOrNothing)Constructs a DML processor with the specified operation and transaction behavior.
global PROC_ExecuteDML(DML_Builder.DatabaseOperation operation, Boolean allOrNothing, AccessLevel accessLevel)Constructs a DML processor with an explicit AccessLevel.

Method Details

PROC_ExecuteDML

apex
global PROC_ExecuteDML(DML_Builder.DatabaseOperation operation)

Constructs a DML processor with the specified operation and default all-or-nothing behavior. Access mode inherits the flag-driven default.

Parameters:

Since: 1.0

Example:

apex
PROC_ExecuteDML processor = new PROC_ExecuteDML(DML_Builder.DatabaseOperation.DML_INSERT);

PROC_ExecuteDML

apex
global PROC_ExecuteDML(DML_Builder.DatabaseOperation operation, Boolean allOrNothing)

Constructs a DML processor with the specified operation and transaction behavior. Access mode inherits the flag-driven default.

Parameters:

  • operation (DML_Builder.DatabaseOperation) - The DML operation to perform (DML_INSERT, DML_UPDATE, DML_DELETE, DML_UPSERT, DML_UNDELETE).
  • allOrNothing (Boolean) - If true, the entire transaction rolls back on any failure; if false, allows partial success.

Since: 1.0

Example:

apex
PROC_ExecuteDML processor = new PROC_ExecuteDML(DML_Builder.DatabaseOperation.DML_UPDATE, false);

PROC_ExecuteDML

apex
global PROC_ExecuteDML(DML_Builder.DatabaseOperation operation, Boolean allOrNothing, AccessLevel accessLevel)

Constructs a DML processor with an explicit AccessLevel. Use this overload when the async commit must pin a specific access mode regardless of the UserModeDml_Enabled flag — framework utilities that own their lifecycle pass AccessLevel.SYSTEM_MODE, and the DML_Builder.async() path passes the caller's chosen AccessLevel so subscriber .withUserMode() opt-ins survive the sync-to-async boundary.

Parameters:

  • operation (DML_Builder.DatabaseOperation) - The DML operation to perform (DML_INSERT, DML_UPDATE, DML_DELETE, DML_UPSERT, DML_UNDELETE).
  • allOrNothing (Boolean) - If true, the entire transaction rolls back on any failure; if false, allows partial success.
  • accessLevel (AccessLevel) - Explicit AccessLevel for the DML commit, or null to inherit the flag-driven default.

Since: 1.0

Example:

apex
PROC_ExecuteDML processor = new PROC_ExecuteDML(DML_Builder.DatabaseOperation.DML_DELETE, true, AccessLevel.SYSTEM_MODE);

execute

apex
global void execute(List<Object> items)

Executes the configured DML operation on the provided list of records.

Parameters:

  • items (List) - The list of SObject records to process.

Since: 1.0

Example:

apex
List<Account> accounts = new List<Account>();
accounts.add(new Account(Name = 'Test'));
new PROC_ExecuteDML(DML_Builder.DatabaseOperation.DML_INSERT).execute(accounts);