Try to implement the DATABASE namespace and its classes to handle the error in run time . Try to refer the docment "apex Language Reference , go to page number 756 and study you will get idea" By this you can get your all error in debug log like this: This is a simple example for handling the error now you cn implement in the same way in batch apex;
Account[]accList = new list<Account>
{new Account(name ='Account1'),
new Account()};
// created one empty and one correct Account
DataBase.SaveResult[] sr = Database.insert(accList,false);
//iterate through each returned list
for(Database.saveResult srl:sr)
{
if(srl.isSuccess())
{
system.debug('successfully inserted Account. Id is :'+srl.getId());
}
else
{
for(DataBase.Error err:srl.getErrors())
{
system.debug('Following are the errors');
system.debug(err.getStatusCode()+':'+err.getMessage());
system.debug('following field affected'+err.getFields());
}
}
}
Try to implement the DATABASE namespace and its classes to handle the error in run time . Try to refer the docment "apex Language Reference , go to page number 756 and study you will get idea" By this you can get your all error in debug log like this: This is a simple example for handling the error now you cn implement in the same way in batch apex;
Account[]accList = new list<Account>
{new Account(name ='Account1'),
new Account()};
// created one empty and one correct Account
DataBase.SaveResult[] sr = Database.insert(accList,false);
//iterate through each returned list
for(Database.saveResult srl:sr)
{
if(srl.isSuccess())
{
system.debug('successfully inserted Account. Id is :'+srl.getId());
}
else
{
for(DataBase.Error err:srl.getErrors())
{
system.debug('Following are the errors');
system.debug(err.getStatusCode()+':'+err.getMessage());
system.debug('following field affected'+err.getFields());
}
}
}
HIi Geetha, procedure will be same only method will be changed.First write your code for update .For update operation it will be like this
Database.saveResult [] sr = Database.update(instanceName,TRUE/False); // here update is a method of database class
// To collect the result of INSERT and UPDATE operation same one class that is SaveResult class is used. for delete there is DeleteResult class is there .
If you want more detail info about these classes then please refer the above document and go to page number:114 you will get all the classes that is used in DML operation by using Database Namespace.
Try to implement the DATABASE namespace and its classes to handle the error in run time . Try to refer the docment "apex Language Reference , go to page number 756 and study you will get idea" By this you can get your all error in debug log like this:
This is a simple example for handling the error now you cn implement in the same way in batch apex;
If you got it then mark as a best answer.
Thanks
Rishav
All Answers
Try to implement the DATABASE namespace and its classes to handle the error in run time . Try to refer the docment "apex Language Reference , go to page number 756 and study you will get idea" By this you can get your all error in debug log like this:
This is a simple example for handling the error now you cn implement in the same way in batch apex;
If you got it then mark as a best answer.
Thanks
Rishav
If we do updation than how we can hadle errors.
procedure will be same only method will be changed.First write your code for update .For update operation it will be like this
Database.saveResult [] sr = Database.update(instanceName,TRUE/False); // here update is a method of database class
// To collect the result of INSERT and UPDATE operation same one class that is SaveResult class is used. for delete there is DeleteResult class is there .
If you want more detail info about these classes then please refer the above document and go to page number:114 you will get all the classes that is used in DML operation by using Database Namespace.
Thanks
Rishav
Now it is clear to me.
U asked me to refer in apex reference document , can u please send me the link for that document
Thank You.
This is the link yo can refer and download the document.
http://www.salesforce.com/us/developer/docs/apexcode/salesforce_apex_language_reference.pdf
Thanks
Rishav