function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
nitin sharmanitin sharma 

Database class

Hi All,

I am getting an error:-Invalid type: Database.SaveResult on Line 6.I have taken this code from the book and it is not running.

I understand that database is the namespace used here,Can I just mention Saveresult and Error class name without attaching database methods.

Can somebody please help?

public class fit
{
public void Passorfail(list<account>pass)
{

Database.SaveResult[] srList = Database.insert(pass, false);
// Iterate through each returned result
for (Database.SaveResult sr : srList) {
    if (sr.isSuccess()) {
        // Operation was successful, so get the ID of the record that was processed
        System.debug('Successfully inserted account. Account ID: ' + sr.getId());
    }
    else {
        // Operation failed, so get all errors               
        for(database.Error err : sr.getErrors()) {
            System.debug('The following error has occurred.');                   
            System.debug(err.getStatusCode() + ': ' + err.getMessage());
            System.debug('Account fields that affected this error: ' + err.getFields());
        }
    }
}


}
}
nitin sharmanitin sharma
I got it ,no worries.