
set @totalInstallment=
(
select sum(InstalledAmount)
from Installments where 
National_ID=new.National_ID
);
if @totalInstallment>@ActualDebt
then
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'The user has already Complited the loan';
end if;
 end if;
 end $$