TR_SALESDEPOSITTEMPLATE_INSERTUPDATE_VALIDBANKACCOUNT

Definition

Copy


create trigger TR_SALESDEPOSITTEMPLATE_INSERTUPDATE_VALIDBANKACCOUNT on dbo.SALESDEPOSITTEMPLATE after insert not for replication
as begin
        set nocount on;

        declare @CURRENTDATE datetime = getDate()
        declare @USERID uniqueidentifier;
        exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @USERID output

    if exists (select 1 
      from inserted i
        inner join dbo.SALESDEPOSITPROCESS SDP on SDP.ID = i.SALESDEPOSITPROCESSID
        inner join dbo.BANKACCOUNT BA on BA.ID = i.BANKACCOUNTID
      where BA.PDACCOUNTSYSTEMID <> SDP.PDACCOUNTSYSTEMID)
    begin
      raiserror('ERR_SALESDEPOSITTEMPLATE_VALIDBANKACCOUNT', 16, 1);
      rollback;
    end
end