---
schema_version: "1"
id: b31e76470b2211e9f0041628220ca2bb0c58c9dfb928d0341ea8cfb52c19ec72
title: Batchable Interface
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexref/apex_interface_database_batchable.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_interface_database_batchable.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: afc5a178062b345727e26e799ffd47310cd92f1eb7fd6859e9f7c3d74e7c796c
description: The class that implements this interface can be executed as a batch Apex job.Gets invoked when the batch job executes and operates on one batch of records. Contains or calls the main execution logic for the batch job.Gets invoked when the batch job finishes. Place any clean up code in this method.Gets invoked when the batch job starts. Returns the record set as an iterable that will be batched for execution.Gets invoked when the batch job starts. Returns the record set as a QueryLocator object that will be batched for execution.
---
# Batchable Interface

The class that implements this interface can be executed as a batch Apex job.

## Namespace

[Database](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_Database.htm "The Database namespace provides classes used with DML operations.")

#### See Also

- [_Apex Developer Guide_: Using Batch](https://developer.salesforce.com/docs/atlas.en-us.264.0.apexcode.meta/apexcode/apex_batch_interface.htm "Apex Developer Guide: Using Batch - HTML (New Window)")

## Batchable Methods

The following are methods for Batchable.

- **[execute(jobId, recordList)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_interface_database_batchable.htm#apex_Database_Batchable_execute)**  
    Gets invoked when the batch job executes and operates on one batch of records. Contains or calls the main execution logic for the batch job.
- **[finish(jobId)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_interface_database_batchable.htm#apex_Database_Batchable_finish)**  
    Gets invoked when the batch job finishes. Place any clean up code in this method.
- **[start(jobId)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_interface_database_batchable.htm#apex_Database_Batchable_start)**  
    Gets invoked when the batch job starts. Returns the record set as an iterable that will be batched for execution.
- **[start(jobId)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_interface_database_batchable.htm#apex_Database_Batchable_start_2)**  
    Gets invoked when the batch job starts. Returns the record set as a QueryLocator object that will be batched for execution.

### execute(jobId, recordList)

Gets invoked when the batch job executes and operates on one batch of records. Contains or calls the main execution logic for the batch job.

#### Signature

public Void execute(Database.BatchableContext jobId, List<sObject> recordList)

#### Parameters

- **jobId**: Type: [Database.BatchableContext](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_interface_database_batchablecontext.htm#apex_interface_database_batchablecontext "Represents the parameter type of a batch job method and contains the batch job ID. This interface is implemented internally by Apex.") Contains the job ID.
- **recordList**: Type: [List](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_list.htm#apex_methods_system_list "Contains methods for the List collection type.")<[sObject](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_sobject.htm#apex_methods_system_sobject "Contains methods for the sObject data type.")\> Contains the batch of records to process.

#### Return Value

Type: Void

### finish(jobId)

Gets invoked when the batch job finishes. Place any clean up code in this method.

#### Signature

public Void finish(Database.BatchableContext jobId)

#### Parameters

- **jobId**: Type: [Database.BatchableContext](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_interface_database_batchablecontext.htm#apex_interface_database_batchablecontext "Represents the parameter type of a batch job method and contains the batch job ID. This interface is implemented internally by Apex.") Contains the job ID.

#### Return Value

Type: Void

### start(jobId)

Gets invoked when the batch job starts. Returns the record set as an iterable that will be batched for execution.

#### Signature

public System.Iterable start(Database.BatchableContext jobId)

#### Parameters

- **jobId**: Type: [Database.BatchableContext](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_interface_database_batchablecontext.htm#apex_interface_database_batchablecontext "Represents the parameter type of a batch job method and contains the batch job ID. This interface is implemented internally by Apex.") Contains the job ID.

#### Return Value

Type: System.Iterable

### start(jobId)

Gets invoked when the batch job starts. Returns the record set as a QueryLocator object that will be batched for execution.

#### Signature

public Database.QueryLocator start(Database.BatchableContext jobId)

#### Parameters

- **jobId**: Type: [Database.BatchableContext](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_interface_database_batchablecontext.htm#apex_interface_database_batchablecontext "Represents the parameter type of a batch job method and contains the batch job ID. This interface is implemented internally by Apex.") Contains the job ID.

#### Return Value

Type: [Database.QueryLocator](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_database_batch.htm#apex_methods_system_database_batch "Represents the record set returned by Database.getQueryLocator and used with Batch Apex.")