I have a code which executes when a new contact is inserted or updated. But when i tried to insert bulk contacts through data loader, the system is throwing following error
"ContatctoAccount: System.LimitException: Apex CPU time limit exceeded".
Below is my code
trigger ContatctoAccount on Contact (after insert, after update) {
list<Contact> Cont = new list<Contact>();
list<Account> Acc = [select id,Account_code__c from Account where Account_code__c != Null];
for(Contact Cnt : trigger.new){
if(Acc.size()>0){
for(Account a : Acc){
for(Contact c: trigger.new){
if(c.Account_code__c == a.Account_code__c){
c.AccountID = a.id;
}
Cont.add(c);
}
}
}
}
}
Can anyone from here please help me solving this error. Thank you in advance