• No results found

Database Methods

In document Salesforce Apex Language Reference (Page 177-184)

Apex Standard Classes and Methods

Description Return Type

Arguments Name

Converts a lead into an account and contact, as well as (optionally) an opportunity

The optional opt_allOrNoneparameter specifies whether the operation allows partial success. If you LeadConvertResult

LeadConvert leadToConvert, Boolean opt_allOrNone convertLead

specify false for this parameter and a record fails, the remainder of the DML operation can still succeed. This method returns a result object that can be used to verify which records succeeded, which failed, and why.

For additional information on the database DML operations, see Apex Data Manipulation Language (DML) Operations on page 156.

Converts a list of LeadConvert objects into accounts and contacts, as well as (optionally) opportunties.

The optional opt_allOrNoneparameter specifies whether the operation allows partial success. If you LeadConvert

specify false for this parameter and a record fails, the remainder of the DML operation can still succeed. This method returns a result object that can be used to verify which records succeeded, which failed, and why.

For additional information on the database DML operations, see Apex Data Manipulation Language (DML) Operations on page 156.

Returns the number of records that a dynamic SOQL query would return when executed. For example,

For more information, see Dynamic SOQL on page 113.

Deletes an existing sObject record, such as an individual account or contact, from your DeleteResult

sObject recordToDelete Boolean opt_allOrNone delete

organization's data.delete is analogous to the DELETE statement in the Force.com Web Services API.

The optional opt_allOrNoneparameter specifies whether the operation allows partial success. If you specify false for this parameter and a record fails, the remainder of the DML operation can still succeed. This method returns a result object that can be used to verify which records succeeded, which failed, and why.

Apex Standard Classes and Methods

Description Return Type

Arguments Name

For additional information on the database DML operations, see Apex Data Manipulation Language (DML) Operations on page 156.

Deletes a list of existing sObject records, such as individual accounts or contacts, from your DeleteResult[]

sObject[] recordsToDelete Boolean opt_allOrNone delete

organization’s data.delete is analogous to the DELETE statement in the Force.com Web Services API.

The optional opt_allOrNoneparameter specifies whether the operation allows partial success. If you specify false for this parameter and a record fails, the remainder of the DML operation can still succeed. This method returns a result object that can be used to verify which records succeeded, which failed, and why.

For additional information on the database DML operations, see Apex Data Manipulation Language (DML) Operations on page 156.

Deletes existing sObject records, such as individual accounts or contacts, from your organization’s data.

DeleteResult RecordID ID

Boolean opt_allOrNone delete

delete is analogous to the DELETE statement in the Force.com Web Services API.

The optional opt_allOrNoneparameter specifies whether the operation allows partial success. If you specify false for this parameter and a record fails, the remainder of the DML operation can still succeed. This method returns a result object that can be used to verify which records succeeded, which failed, and why.

For additional information on the database DML operations, see Apex Data Manipulation Language (DML) Operations on page 156.

Deletes a list of existing sObject records, such as individual accounts or contacts, from your DeleteResult[]

RecordIDs []IDs

Boolean opt_allOrNone delete

organization’s data.delete is analogous to the DELETE statement in the Force.com Web Services API.

The optional opt_allOrNoneparameter specifies whether the operation allows partial success. If you specify false for this parameter and a record fails, the remainder of the DML operation can still succeed. This method returns a result object that can be used to verify which records succeeded, which failed, and why.

Apex Standard Classes and Methods

Description Return Type

Arguments Name

For additional information on the database DML operations, see Apex Data Manipulation Language (DML) Operations on page 156.

Creates a QueryLocator object used in Apex managed sharing or Visualforce. For more QueryLocator

sObject [] listOfQueries getQueryLocator

information, see Database Batch Objects and Methods on page 182,Apex Managed Sharing on page 117, and StandardSetController Class on page 251.

Adds an sObject, such as an individual account or contact, to your organization's data.insert is analogous to the INSERT statement in SQL.

The optional opt_allOrNoneparameter specifies whether the operation allows partial success. If you SaveResult

sObject recordToInsert Boolean opt_allOrNone insert

specify false for this parameter and a record fails, the remainder of the DML operation can still succeed. This method returns a result object that can be used to verify which records succeeded, which failed, and why.

For additional information on the database DML operations, see Apex Data Manipulation Language (DML) Operations on page 156.

Adds one or more sObjects, such as individual accounts or contacts, to your organization’s data.

SaveResult[]

sObject [] recordsToInsert Boolean opt_allOrNone insert

insert is analogous to the INSERT statement in SQL.

The optional opt_allOrNoneparameter specifies whether the operation allows partial success. If you specify false for this parameter and a record fails, the remainder of the DML operation can still succeed. This method returns a result object that can be used to verify which records succeeded, which failed, and why.

For additional information on the database DML operations, see Apex Data Manipulation Language (DML) Operations on page 156.

Creates a dynamic SOQL query at runtime that limits the number of sObjects returned to a single sObject

String query query

object, generally by specifying limit = 1 as part of the select statement. This method can be used wherever a static SOQL query can be used, such as in regular assignment statements and for loops.

For more information, see Dynamic SOQL on page 113.

Apex Standard Classes and Methods

Description Return Type

Arguments Name

Creates a dynamic SOQL query at runtime. This method can be used wherever a static SOQL query sObject[]

String query query

can be used, such as in regular assignment statements and for loops.

For more information, see Dynamic SOQL on page 113.

Restores the database to the state specified by the savepoint variable. Any emails submitted since the last savepoint are also rolled back and not sent.

You can only restore the database using rollback 20 times in all contexts, that is, in triggers, Void

Savepoint sp rollback

anonymous blocks, WSDL methods or unit tests.

You will receive a runtime error if you try to rollback the database additional times.

Returns a savepoint variable that can be stored as a local variable, then used with the rollback method to restore the database to that point.

If you set more than one savepoint, then roll back to a savepoint that is not the last savepoint you Savepoint

setSavepoint

generated, the later savepoint variables become invalid. For example, if you generated savepoint SP1 first, savepoint SP2 after that, and then you rolled back to SP1, the variable SP2 would no longer be valid. You will receive a runtime error if you try to use it.

References to savepoints cannot cross trigger invocations, because each trigger invocation is a new execution context. If you declare a savepoint as a static variable then try to use it across trigger contexts you will receive a runtime error.

You can only set five savepoints in all contexts, that is, in triggers, anonymous blocks, WSDL methods or unit tests. You will receive a runtime error if you try to set additional savepoints.

Restores an existing sObject record, such as an individual account or contact, from your UndeleteResult

sObject recordToUndelete Boolean opt_allOrNone undelete

organization's Recycle Bin.undelete is analogous to the UNDELETE statement in SQL.

The optional opt_allOrNoneparameter specifies whether the operation allows partial success. If you specify false for this parameter and a record fails, the remainder of the DML operation can still succeed. This method returns a result object that can be used to verify which records succeeded, which failed, and why.

Apex Standard Classes and Methods

Description Return Type

Arguments Name

For additional information on the database DML operations, see Apex Data Manipulation Language (DML) Operations on page 156.

Restores one or more existing sObject records, such as individual accounts or contacts, from your UndeleteResult[]

sObject []

recordsToUndelete Boolean opt_allOrNone undelete

organization’s Recycle Bin.undelete is analogous to the UNDELETE statement in SQL.

The optional opt_allOrNoneparameter specifies whether the operation allows partial success. If you specify false for this parameter and a record fails, the remainder of the DML operation can still succeed. This method returns a result object that can be used to verify which records succeeded, which failed, and why.

For additional information on the database DML operations, see Apex Data Manipulation Language (DML) Operations on page 156.

Restores an existing sObject record, such as an individual account or contact, from your UndeleteResult

RecordID ID

Boolean opt_allOrNone undelete

organization's Recycle Bin.undelete is analogous to the UNDELETE statement in SQL.

The optional opt_allOrNoneparameter specifies whether the operation allows partial success. If you specify false for this parameter and a record fails, the remainder of the DML operation can still succeed. This method returns a result object that can be used to verify which records succeeded, which failed, and why.

For additional information on the database DML operations, see Apex Data Manipulation Language (DML) Operations on page 156.

Restores one or more existing sObject records, such as individual accounts or contacts, from your UndeleteResult[]

RecordIDs[] ID

Boolean opt_allOrNone undelete

organization’s Recycle Bin.undelete is analogous to the UNDELETE statement in SQL.

The optional opt_allOrNoneparameter specifies whether the operation allows partial success. If you specify false for this parameter and a record fails, the remainder of the DML operation can still succeed. This method returns a result object that can be used to verify which records succeeded, which failed, and why.

For additional information on the database DML operations, see Apex Data Manipulation Language (DML) Operations on page 156.

Apex Standard Classes and Methods

Description Return Type

Arguments Name

Modifies an existing sObject record, such as an individual account or contact, in your organization's UpdateResult

sObject recordToUpdate Boolean opt_allOrNone update

data.update is analogous to the UPDATE statement in SQL.

The optional opt_allOrNoneparameter specifies whether the operation allows partial success. If you specify false for this parameter and a record fails, the remainder of the DML operation can still succeed. This method returns a result object that can be used to verify which records succeeded, which failed, and why.

For additional information on the database DML operations, see Apex Data Manipulation Language (DML) Operations on page 156.

Modifies one or more existing sObject records, such as individual accounts or contacts, in your

UpdateResult[]

sObject [] recordsToUpdate Boolean opt_allOrNone update

organization’s data.update is analogous to the UPDATE statement in SQL.

The optional opt_allOrNoneparameter specifies whether the operation allows partial success. If you specify false for this parameter and a record fails, the remainder of the DML operation can still succeed. This method returns a result object that can be used to verify which records succeeded, which failed, and why.

For additional information on the database DML operations, see Apex Data Manipulation Language (DML) Operations on page 156.

Creates a new sObject record or updates an existing sObject record within a single statement, using an UpsertResult

sObject recordToUpsert Object.External_ID_Field upsert

optional custom field to determine the presence of existing objects.

Object.External_ID_Field requires both the object and the custom field name, which are verified Boolean opt_allOrNone

when you save your Apex script. For example, Account.MyExternalId.

The optional opt_allOrNoneparameter specifies whether the operation allows partial success. If you specify false for this parameter and a record fails, the remainder of the DML operation can still succeed. This method returns a result object that can be used to verify which records succeeded, which failed, and why.

For additional information on the database DML operations, see Apex Data Manipulation Language (DML) Operations on page 156.

Apex Standard Classes and Methods

Description Return Type

Arguments Name

Creates new sObject records and updates existing sObject records within a single statement, using an UpsertResult[]

sObject [] recordsToUpsert Object.External_ID_Field upsert

optional custom field to determine the presence of existing objects.

Object.External_ID_Field requires both the object and the custom field name, which are verified Boolean opt_allOrNone

when you save your Apex script. For example, Account.MyExternalId.

The optional opt_allOrNoneparameter specifies whether the operation allows partial success. If you specify false for this parameter and a record fails, the remainder of the DML operation can still succeed. This method returns a result object that can be used to verify which records succeeded, which failed, and why.

For additional information on the database DML operations, see Apex Data Manipulation Language (DML) Operations on page 156.

In document Salesforce Apex Language Reference (Page 177-184)