You need to sign in to do that
Don't have an account?

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());
}
}
}
}
}
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());
}
}
}
}
}

I got it ,no worries.