ALTER trigger [dbo].[tr_LedgerJournalTrans_InsUpdDel] on [dbo].[LEDGERJOURNALTRANS]
for insert, update, delete
as
begin
set nocount on
update pd
set pd.SISADP = isnull(
(select sum((AMOUNTCURDEBIT - AMOUNTCURCREDIT))
from LedgerJournalTrans ljt
where pd.NOMOR_PURCHDP = ljt.NOMOR_DP and pd.DATAAREAID = ljt.DATAAREAID and pd.PARTITION = ljt.PARTITION), 0)
from PURCHDP_HEADER pd
where exists (
select 1
from deleted d
where isnull(d.NOMOR_DP, '') <> '' and pd.NOMOR_PURCHDP = d.NOMOR_DP and pd.DATAAREAID = d.DATAAREAID and pd.PARTITION = d.PARTITION
)
or
exists (
select 1
from inserted i
where isnull(i.NOMOR_DP, '') <> '' and pd.NOMOR_PURCHDP = i.NOMOR_DP and pd.DATAAREAID = i.DATAAREAID and pd.PARTITION = i.PARTITION
)
set nocount off
end
Tidak ada komentar:
Posting Komentar