dbo.CPL_TUPersonInBaseTree
Database TriggerSQL_TRIGGERSandbox DB
Interpretation
- Database trigger. Treat parent table and enqueue/object-layer calls as the main relation points.
Relations
- Trigger parent table: PersonInBaseTree
Typed Edges
- trigger on table PersonInBaseTree Trigger parent table: PersonInBaseTree
- references source dbo.QBM_FGIConfigparmValue source text reference
- references source dbo.QBM_FGISessionContext source text reference
- references source dbo.QBM_PSessionErrorAdd source text reference
- references source dbo.CPL_TUPerson source text reference
References
Referenced By
- No direct source references extracted.
Complete Source
1CREATE trigger CPL_TUPersonInBaseTree2 ON PersonInBaseTree FOR3UPDATE NOT FOR Replication4AS5BEGIN6 DECLARE @XUser nvarchar(64) = object_name(@@procid)7 DECLARE @Xdate datetime = getutcdate()8 BEGIN TRY9 IF EXISTS(10 SELECT TOP 1 111 FROM deleted)12 GOTO start13 IF EXISTS(14 SELECT TOP 1 115 FROM inserted)16 GOTO start17 RETURN start:18 DECLARE @GenProcID varchar(38)19 SELECT @GenProcID = dbo.QBM_FGISessionContext('')20 IF21 UPDATE(IsDecisionMade) OR22 UPDATE(IsExceptionGranted) OR23 UPDATE(UID_PersonDecisionMade)24 BEGIN25 IF dbo.QBM_FGIConfigparmValue('QER\ComplianceCheck\DisableSelfExceptionGranting') = '1'26 BEGIN27 IF EXISTS(28 SELECT TOP 1 129 FROM deleted i30 JOIN personInBaseTree pio31 ON i.XObjectKey = pio.XObjectKey32 JOIN BaseTree b33 ON pio.uid_org = b.uid_org AND b.uid_orgRoot = 'CPL-V-NonCompliance'34 JOIN QER_VPersonsAreMe me35 ON pio.UID_PersonDecisionMade = me.UID_PersonOrigin AND pio.UID_Person = me.UID_PersonAlsoMe36 WHERE37 pio.IsDecisionMade = 1 AND pio.IsExceptionGranted = 1)38 BEGIN39 RAISERROR('#LDS#Cannot make assignment because not permitted according to configuration of DisableSelfExceptionGranting.|',40 18,41 3)42 WITH nowait43 END44 END45 END46 IF47 UPDATE(XOrigin)48 BEGIN49 IF EXISTS(50 SELECT TOP 1 151 FROM deleted d52 JOIN PersonInBaseTree pio53 ON d.XObjectKey = pio.XObjectKey54 JOIN BaseTree b55 ON pio.UID_Org = b.UID_Org AND b.UID_OrgRoot = 'CPL-V-NonCompliance'56 WHERE57 d.XOrigin > 0 AND pio.XOrigin = 0)58 BEGIN59 DELETE PersonInNCHasMControl60 FROM PersonInNCHasMControl pmc61 JOIN deleted d62 ON pmc.ObjectKeyPersonInNonCompliance = d.XObjectKey63 JOIN PersonInBaseTree pio64 ON d.XObjectKey = pio.XObjectKey65 JOIN BaseTree b66 ON pio.UID_Org = b.UID_Org AND b.UID_OrgRoot = 'CPL-V-NonCompliance'67 WHERE68 d.XOrigin > 0 AND pio.XOrigin = 0 AND pmc.UID_PersonWantsOrg IS NULL69 UPDATE PersonInNCHasMControl70 SET IsInActive = 1,71 XDateUpdated = @Xdate,72 XUserUpdated = @XUser73 FROM PersonInNCHasMControl pmc74 JOIN deleted d75 ON pmc.ObjectKeyPersonInNonCompliance = d.XObjectKey76 JOIN PersonInBaseTree pio77 ON d.XObjectKey = pio.XObjectKey78 JOIN BaseTree b79 ON pio.UID_Org = b.UID_Org AND b.UID_OrgRoot = 'CPL-V-NonCompliance'80 WHERE81 d.XOrigin > 0 AND pio.XOrigin = 0 AND pmc.UID_PersonWantsOrg > ' '82 END83 END84 END TRY85 BEGIN CATCH86 EXEC QBM_PSessionErrorAdd DEFAULT87 RAISERROR('',88 18,89 1)90 WITH NOWAIT91 END CATCH92 ende:93 RETURN94END
Open raw exported source
1create trigger CPL_TUPersonInBaseTree on PersonInBaseTree for Update not for Replication as begin declare @XUser nvarchar(64) = object_name2(@@procid) declare @Xdate datetime = getutcdate() BEGIN TRY if exists (select top 1 1 from deleted) goto start if exists (select top 1 1 from inserted)3 goto start return start: declare @GenProcID varchar(38) select @GenProcID = dbo.QBM_FGISessionContext('') if update(IsDecisionMade) or update(IsExceptionGranted4) or update(UID_PersonDecisionMade) begin if dbo.QBM_FGIConfigparmValue('QER\ComplianceCheck\DisableSelfExceptionGranting') = '1' begin if exists (select5 top 1 1 from deleted i join personInBaseTree pio on i.XObjectKey = pio.XObjectKey join BaseTree b on pio.uid_org = b.uid_org and b.uid_orgRoot = 'CPL-V-NonCompliance'6 join QER_VPersonsAreMe me on pio.UID_PersonDecisionMade = me.UID_PersonOrigin and pio.UID_Person = me.UID_PersonAlsoMe where pio.IsDecisionMade = 1 and7 pio.IsExceptionGranted = 1 ) begin raiserror( '#LDS#Cannot make assignment because not permitted according to configuration of DisableSelfExceptionGranting.|'8, 18, 3) with nowait end end end if update(XOrigin) begin if exists (select top 1 1 from deleted d join PersonInBaseTree pio on d.XObjectKey = pio.XObjectKey9 join BaseTree b on pio.UID_Org = b.UID_Org and b.UID_OrgRoot = 'CPL-V-NonCompliance' where d.XOrigin > 0 and pio.XOrigin = 0 ) begin delete PersonInNCHasMControl10 from PersonInNCHasMControl pmc join deleted d on pmc.ObjectKeyPersonInNonCompliance = d.XObjectKey join PersonInBaseTree pio on d.XObjectKey = pio.XObjectKey11 join BaseTree b on pio.UID_Org = b.UID_Org and b.UID_OrgRoot = 'CPL-V-NonCompliance' where d.XOrigin > 0 and pio.XOrigin = 0 and pmc.UID_PersonWantsOrg12 is null update PersonInNCHasMControl set IsInActive = 1 , XDateUpdated = @Xdate , XUserUpdated = @XUser from PersonInNCHasMControl pmc join deleted13 d on pmc.ObjectKeyPersonInNonCompliance = d.XObjectKey join PersonInBaseTree pio on d.XObjectKey = pio.XObjectKey join BaseTree b on pio.UID_Org = b.UID_Org14 and b.UID_OrgRoot = 'CPL-V-NonCompliance' where d.XOrigin > 0 and pio.XOrigin = 0 and pmc.UID_PersonWantsOrg > ' ' end end END TRY BEGIN CATCH exec QBM_PSessionErrorAdd15 default RAISERROR ('', 18, 1) WITH NOWAIT END CATCH ende: return end 16