I am new to apex. I have two objects blood_bank__c and patient__c. I want to change quantity of blood in blood bank after patient is given some blood. This trigger is not working, and its not allowing me to add new patient.
trigger :
trigger bloodcalTrigger on patient__c ( after update, after insert) {
patient__c tok = [ Select blood_quantity_used__c, Blood_group_del__c From patient__c];
blood_bank__c cons = [Select quantity__c, name From blood_bank__c];
if(tok.Blood_group_del__c == cons.name ) {
cons.quantity__c = cons.quantity__c - tok.blood_quantity_used__c ;
}else {}
}