+ Start a Discussion
sai manojsai manoj 

how to write a apex program to insert list of account with list of contact method as parameter

-Input - list of accounts, list of contacts
-action- save in database

if record of account and corresponding contact has been failed that record has not insert
Note  -- create method signature-(method with parameters) as list of accounts and list of contacts parameters - list<Account>accts, list<contact>conts 
---- Create save point
insert accounts from parameter
insert contacts from parameter
 -- roll back in case of exception
please give any guidance if any one know
Raj VakatiRaj Vakati
Use this code
 
public class savePointExample {

  public void savePointRollBack(List<Account> accList , List<Contact> conList) {
	 Savepoint sp = Database.setSavepoint();
	try{
  
     insert accList;
     insert conList;
 
   } catch(DMLException exc) {
      Database.rollback(sp);

  }  
 }

}

 
sai manojsai manoj
Thanks Raj for this i want to write apex trigger for this which events i want to use
please guide me