Back to OIM Explorer

dbo.QER_TUOrgType

Database TriggerSQL_TRIGGERSandbox DB

Database Trigger on OrgType. Trigger parent table: OrgType

Source: sandbox-db sys.sql_modules

Source size: 1.498 characters

Interpretation

  • Database trigger. Treat parent table and enqueue/object-layer calls as the main relation points.

Relations

  • Trigger parent table: OrgType

Typed Edges

  • trigger on table OrgType Trigger parent table: OrgType
  • references source dbo.QBM_FGISessionContext source text reference
  • references source dbo.QBM_PSessionErrorAdd source text reference

References

Referenced By

  • No direct source references extracted.

Complete Source

SQL79 lines
1CREATE trigger QER_TUOrgType2  ON OrgType FOR3UPDATE NOT FOR Replication4AS5BEGIN6  BEGIN TRY7    IF EXISTS(8      SELECT TOP 1 19      FROM inserted)10    GOTO start11    IF EXISTS(12      SELECT TOP 1 113      FROM deleted)14    GOTO start15    RETURN start:16    DECLARE @GenProcID varchar(38)17    SELECT @GenProcID = dbo.QBM_FGISessionContext('')18    IF19    UPDATE(IsPersonAssignOnce)20    BEGIN21      IF EXISTS(22        SELECT TOP 1 123        FROM OrgType t24        JOIN deleted d25          ON t.UID_OrgType = d.UID_OrgType26        WHERE27          t.IsPersonAssignOnce = 1 AND EXISTS(28        SELECT TOP 1 129        FROM PersonInBaseTree pib30        JOIN BaseTree b31          ON pib.UID_Org = b.UID_Org32        JOIN OrgRoot r33          ON b.UID_OrgRoot = r.UID_OrgRoot AND r.UID_OrgType = t.UID_OrgType34        GROUP BY pib.UID_Person35        HAVING count(*) > 1))36      BEGIN37        RAISERROR('#LDS#IsPersonAssignOnce cannot be set, because at least one person is assigned to a role class in this role type more than once.|'38        ,39        18,40        2)41          WITH nowait42      END43    END44    IF45    UPDATE(IsPersonAssignOnce)46    BEGIN47      IF EXISTS(48        SELECT TOP 1 149        FROM OrgType t50        JOIN deleted d51          ON t.UID_OrgType = d.UID_OrgType52        WHERE53          t.IsPersonAssignOnce = 1 AND EXISTS(54        SELECT TOP 1 155        FROM PersonInBaseTree pib56        JOIN BaseTree b57          ON pib.UID_Org = b.UID_Org58        WHERE59          b.UID_OrgType = t.UID_OrgType60        GROUP BY pib.UID_Person61        HAVING count(*) > 1))62      BEGIN63        RAISERROR('#LDS#IsPersonAssignOnce cannot be set, because at least one person is assigned to roles in this role type more than once.|',64        18,65        2)66          WITH nowait67      END68    END69  END TRY70  BEGIN CATCH71    EXEC QBM_PSessionErrorAdd DEFAULT72    RAISERROR('',73    18,74    1)75      WITH NOWAIT76  END CATCH77  ende:78  RETURN79END
Open raw exported source
SQL ยท Raw10 lines
1    create   trigger QER_TUOrgType on OrgType  for UPDATE not for Replication as begin  BEGIN TRY if exists (select top 1 1 from inserted) goto 2start if exists (select top 1 1 from deleted) goto start return start: declare @GenProcID varchar(38) select @GenProcID = dbo.QBM_FGISessionContext('')3  if update (IsPersonAssignOnce) begin if exists (select top 1 1 from OrgType t join deleted d on t.UID_OrgType = d.UID_OrgType where t.IsPersonAssignOnce4 = 1 and exists (select top 1 1 from PersonInBaseTree pib join BaseTree b on pib.UID_Org = b.UID_Org join OrgRoot r on b.UID_OrgRoot = r.UID_OrgRoot and5 r.UID_OrgType = t.UID_OrgType group by pib.UID_Person having count(*) > 1 ) ) begin raiserror( '#LDS#IsPersonAssignOnce cannot be set, because at least one person is assigned to a role class in this role type more than once.|'6, 18, 2) with nowait end end if update (IsPersonAssignOnce) begin if exists (select top 1 1 from OrgType t join deleted d on t.UID_OrgType = d.UID_OrgType7 where t.IsPersonAssignOnce = 1 and exists (select top 1 1 from PersonInBaseTree pib join BaseTree b on pib.UID_Org = b.UID_Org where b.UID_OrgType = t.UID_OrgType8 group by pib.UID_Person having count(*) > 1 ) ) begin raiserror( '#LDS#IsPersonAssignOnce cannot be set, because at least one person is assigned to roles in this role type more than once.|'9, 18, 2) with nowait end end  END TRY BEGIN CATCH exec QBM_PSessionErrorAdd default RAISERROR ('', 18, 1) WITH NOWAIT END CATCH ende: return end 10