CREATE TRIGGER [dbo].[trg_CheckBalance_me]
ON [dbo].[st_havaleh_info]
FOR INSERT,update
AS
BEGIN
SET NOCOUNT ON;
if ((select count_kala from st_seating where Code_kala=(select code_material from inserted )) < ((select count_unit from inserted)-(select count_unit from deleted)))
begin
ROLLBACK TRAN;
RAISERROR ('count of materials are low',16,1);
return
end
END;
go