Back to OIM Explorer

dbo.QBM_TUAssembly_QBMRelation

Database TriggerSQL_TRIGGERSandbox DB

Database Trigger on QBMRelation. Single DBQueue insert -> QBM-K-ScriptAssemblyReset / QBM_ZScriptAssemblyReset at line 4; Bulk DBQueue insert -> QBM-K-CommonMakeWatchtrigger / QBM_ZTriggerWatchCreate at line 4; Bulk DBQueue insert -> QBM-K-CommonMakeWatchtrigger / QBM_ZTriggerWatchCreate at line 4; Single DBQueue insert -> QBM-K-CommonMakeRITriggerPre / QBM_ZRITriggerPrepare at line 4

Source: sandbox-db sys.sql_modules

Source size: 4.689 characters

Interpretation

  • Database trigger. Treat parent table and enqueue/object-layer calls as the main relation points.
  • DBQueue relation detected. Follow the task procedure and referenced-by list for async processing.

Relations

  • Single DBQueue insert -> QBM-K-ScriptAssemblyReset / QBM_ZScriptAssemblyReset at line 4
  • Bulk DBQueue insert -> QBM-K-CommonMakeWatchtrigger / QBM_ZTriggerWatchCreate at line 4
  • Bulk DBQueue insert -> QBM-K-CommonMakeWatchtrigger / QBM_ZTriggerWatchCreate at line 4
  • Single DBQueue insert -> QBM-K-CommonMakeRITriggerPre / QBM_ZRITriggerPrepare at line 4
  • Bulk DBQueue insert -> QBM-K-CommonMakeWatchtrigger / QBM_ZTriggerWatchCreate at line 10
  • Bulk DBQueue insert -> QBM-K-CommonMakeWatchtrigger / QBM_ZTriggerWatchCreate at line 10
  • Single DBQueue insert -> QBM-K-CommonMakeRITriggerPre / QBM_ZRITriggerPrepare at line 10
  • Bulk DBQueue insert -> QBM-K-CommonMakeWatchtrigger / QBM_ZTriggerWatchCreate at line 19
  • Single DBQueue insert -> QBM-K-CommonMakeRITriggerPre / QBM_ZRITriggerPrepare at line 19
  • Single DBQueue insert -> QBM-K-CommonMakeRITriggerPre / QBM_ZRITriggerPrepare at line 29
  • References QBM_PDBQueueInsert_Single
  • References QBM_PDBQueueInsert_Bulk
  • Trigger parent table: QBMRelation

Typed Edges

  • queues DBQueue task QBM_ZScriptAssemblyReset at line 4 Single DBQueue insert -> QBM-K-ScriptAssemblyReset / QBM_ZScriptAssemblyReset at line 4
  • queues DBQueue task QBM_ZTriggerWatchCreate at line 4 Bulk DBQueue insert -> QBM-K-CommonMakeWatchtrigger / QBM_ZTriggerWatchCreate at line 4
  • queues DBQueue task QBM_ZRITriggerPrepare at line 4 Single DBQueue insert -> QBM-K-CommonMakeRITriggerPre / QBM_ZRITriggerPrepare at line 4
  • queues DBQueue task QBM_ZTriggerWatchCreate at line 10 Bulk DBQueue insert -> QBM-K-CommonMakeWatchtrigger / QBM_ZTriggerWatchCreate at line 10
  • queues DBQueue task QBM_ZRITriggerPrepare at line 10 Single DBQueue insert -> QBM-K-CommonMakeRITriggerPre / QBM_ZRITriggerPrepare at line 10
  • queues DBQueue task QBM_ZTriggerWatchCreate at line 19 Bulk DBQueue insert -> QBM-K-CommonMakeWatchtrigger / QBM_ZTriggerWatchCreate at line 19
  • queues DBQueue task QBM_ZRITriggerPrepare at line 19 Single DBQueue insert -> QBM-K-CommonMakeRITriggerPre / QBM_ZRITriggerPrepare at line 19
  • queues DBQueue task QBM_ZRITriggerPrepare at line 29 Single DBQueue insert -> QBM-K-CommonMakeRITriggerPre / QBM_ZRITriggerPrepare at line 29
  • trigger on table QBMRelation Trigger parent table: QBMRelation
  • references source dbo.QBM_FGISessionContext source text reference
  • references source dbo.QBM_PDBQueueInsert_Bulk source text reference
  • references source dbo.QBM_PDBQueueInsert_Single source text reference
  • references source dbo.QBM_PSessionErrorAdd source text reference

Complete Source

SQL177 lines
1CREATE trigger QBM_TUAssembly_QBMRelation2  ON QBMRelation FOR3UPDATE NOT FOR Replication4AS5BEGIN6  DECLARE @GenProcID varchar(38) = dbo.QBM_FGISessionContext('')7  DECLARE @XUser nvarchar(64) = object_name(@@procid)8  DECLARE @Xdate datetime = getutcdate()9  BEGIN TRY10    IF EXISTS(11      SELECT TOP 1 112      FROM inserted)13    GOTO start14    IF EXISTS(15      SELECT TOP 1 116      FROM deleted)17    GOTO start18    RETURN start:19    IF20    UPDATE(ParentRestriction) OR21    UPDATE(ChildRestriction) OR22    UPDATE(ParentExecuteBy) OR23    UPDATE(ChildExecuteBy)24    BEGIN25      EXEC QBM_PDBQueueInsert_Single 'QBM-K-ScriptAssemblyReset',26      'TypedWrappers',27      '#',28        @GenProcID29    END30    IF31    UPDATE(ismnrelation)32    BEGIN33      DECLARE @DBQueueElements_01 QBM_YDBQueueRaw34      INSERT INTO @DBQueueElements_01(object,35      subobject,36      genprocid)37      SELECT38        x.uid,39        NULL,40        @GenProcID41      FROM(42      SELECT t.TableName AS UID43      FROM QBMRelation i44      JOIN deleted d45        ON i.UID_QBMRelation = d.UID_QBMRelation46      JOIN DialogColumn c47        ON i.UID_ChildColumn = c.UID_DialogColumn48      JOIN DialogTable t49        ON c.UID_DialogTable = t.UID_DialogTable50      WHERE51        isnull(i.ismnRelation, 0) <> isnull(d.ismnRelation, 0) AND i.ParentExecuteBy IN('T', 'D')52      UNION53      SELECT t.TableName AS UID54      FROM QBMRelation i55      JOIN deleted d56        ON i.UID_QBMRelation = d.UID_QBMRelation57      JOIN DialogColumn c58        ON i.UID_ParentColumn = c.UID_DialogColumn59      JOIN DialogTable t60        ON c.UID_DialogTable = t.UID_DialogTable61      WHERE62        isnull(i.ismnRelation, 0) <> isnull(d.ismnRelation, 0) AND i.ParentExecuteBy IN('T', 'D')) AS x63      EXEC QBM_PDBQueueInsert_Bulk 'QBM-K-CommonMakeWatchtrigger',64        @DBQueueElements_0165    END66    IF67    UPDATE(ParentRestriction) OR68    UPDATE(ParentExecuteBy) OR69    UPDATE(ChildRestriction) OR70    UPDATE(ChildExecuteBy) OR71    UPDATE(IsForUpdateXDateSubItem)72    BEGIN73      DECLARE @DBQueueElements_02 QBM_YDBQueueRaw74      INSERT INTO @DBQueueElements_02(object,75      subobject,76      genprocid)77      SELECT78        x.uid,79        NULL,80        @GenProcID81      FROM(82      SELECT t.TableName AS UID83      FROM deleted i84      JOIN QBMRelation r85        ON i.UID_QBMRelation = r.UID_QBMRelation86      JOIN DialogColumn c87        ON i.UID_ParentColumn = c.UID_DialogColumn88      JOIN DialogTable t89        ON c.UID_DialogTable = t.UID_DialogTable90      WHERE91        (r.ParentRestriction <> i.ParentRestriction OR r.ParentExecuteBy <> i.ParentExecuteBy OR r.ChildRestriction <> i.ChildRestriction OR r.ChildExecuteBy92      <> i.ChildExecuteBy OR r.IsForUpdateXDateSubItem <> i.IsForUpdateXDateSubItem) AND r.ParentExecuteBy IN('T',93      'D')94      UNION95      SELECT t.TableName AS UID96      FROM deleted i97      JOIN QBMRelation r98        ON i.UID_QBMRelation = r.UID_QBMRelation99      JOIN DialogColumn c100        ON i.UID_ChildColumn = c.UID_DialogColumn101      JOIN DialogTable t102        ON c.UID_DialogTable = t.UID_DialogTable103      WHERE104        (r.ParentRestriction <> i.ParentRestriction OR r.ParentExecuteBy <> i.ParentExecuteBy OR r.ChildRestriction <> i.ChildRestriction OR r.ChildExecuteBy105      <> i.ChildExecuteBy OR r.IsForUpdateXDateSubItem <> i.IsForUpdateXDateSubItem) AND r.ParentExecuteBy IN('T',106      'D')) AS x107      EXEC QBM_PDBQueueInsert_Bulk 'QBM-K-CommonMakeWatchtrigger',108        @DBQueueElements_02109    END110    IF111    UPDATE(ParentRestriction) OR112    UPDATE(ParentExecuteBy) OR113    UPDATE(ChildRestriction) OR114    UPDATE(ChildExecuteBy) OR115    UPDATE(ParentAllowUpdate)116    BEGIN117      IF EXISTS(118        SELECT TOP 1 1119        FROM QBMRelation r120        JOIN deleted d121          ON r.UID_QBMRelation = d.UID_QBMRelation122        WHERE123          (isnull(r.ParentRestriction, '') <> isnull(d.ParentRestriction, '') OR isnull(r.ParentExecuteBy,124      '') <> isnull(d.ParentExecuteBy, '') OR isnull(r.ChildRestriction, '') <> isnull(d.ChildRestriction, '') OR isnull(r.ChildExecuteBy,125      '') <> isnull(d.ChildExecuteBy, '')))126      BEGIN127        UPDATE QBMRelation128        SET ParentExecuteBy = CASE v.ParentExecuteBy129        WHEN 'N' THEN130        'N'131        ELSE 'T'132        END,133        ParentAllowUpdate = 0,134        ParentRestriction = b.ParentRestriction,135        XDateUpdated = @Xdate,136        XUserUpdated = @XUser137        FROM QBMRelation v138        JOIN inserted b139          ON v.UID_QBMRelationBase = b.UID_QBMRelation140        WHERE141          b.ParentExecuteBy = 'T' AND(v.ParentExecuteBy NOT IN('T', 'N') OR v.ParentAllowUpdate = 1 OR v.ParentRestriction <> b.ParentRestriction142        )143        UPDATE QBMRelation144        SET ParentExecuteBy = CASE v.ParentExecuteBy145        WHEN 'N' THEN146        'N'147        ELSE 'D'148        END,149        ParentAllowUpdate = b.ParentAllowUpdate,150        ParentRestriction = CASE b.ParentAllowUpdate151        WHEN 1 THEN152        v.ParentRestriction153        ELSE b.ParentRestriction154        END,155        XDateUpdated = @Xdate,156        XUserUpdated = @XUser157        FROM QBMRelation v158        JOIN inserted b159          ON v.UID_QBMRelationBase = b.UID_QBMRelation160        WHERE161          b.ParentExecuteBy = 'D' AND(v.ParentExecuteBy NOT IN('D', 'N') OR v.ParentAllowUpdate <> b.ParentAllowUpdate OR(b.ParentAllowUpdate = 0 AND162        b.ParentRestriction <> v.ParentRestriction))163      END164      EXEC QBM_PDBQueueInsert_Single 'QBM-K-CommonMakeRITriggerPre',165      '',166      '',167        @GenProcID168    END169  END TRY170  BEGIN CATCH171    EXEC QBM_PSessionErrorAdd DEFAULT172    RAISERROR('',173    18,174    1)175      WITH NOWAIT176  END CATCH177END
Open raw exported source
SQL ยท Raw31 lines
1  create   trigger QBM_TUAssembly_QBMRelation on QBMRelation  for Update not for Replication as begin declare @GenProcID varchar(38) = dbo.QBM_FGISessionContext2('') declare @XUser nvarchar(64) = object_name(@@procid) declare @Xdate datetime = getutcdate() BEGIN TRY if exists (select top 1 1 from inserted) goto3 start if exists (select top 1 1 from deleted) goto start return start: if update(ParentRestriction) or update(ChildRestriction) or update(ParentExecuteBy4) or update(ChildExecuteBy) begin exec QBM_PDBQueueInsert_Single 'QBM-K-ScriptAssemblyReset', 'TypedWrappers', '#', @GenProcID end  if UPDATE(ismnrelation5) begin  declare @DBQueueElements_01 QBM_YDBQueueRaw insert into @DBQueueElements_01 (object, subobject, genprocid) select x.uid, null, @GenProcID from6 (select t.TableName as UID from QBMRelation i join deleted d on i.UID_QBMRelation = d.UID_QBMRelation join DialogColumn c on i.UID_ChildColumn = c.UID_DialogColumn7 join DialogTable t on c.UID_DialogTable = t.UID_DialogTable where isnull(i.ismnRelation,0) <> isnull(d.ismnRelation,0)  and i.ParentExecuteBy in ('T',8 'D') union select t.TableName as UID from QBMRelation i join deleted d on i.UID_QBMRelation = d.UID_QBMRelation join DialogColumn c on i.UID_ParentColumn9 = c.UID_DialogColumn join DialogTable t on c.UID_DialogTable = t.UID_DialogTable where isnull(i.ismnRelation,0) <> isnull(d.ismnRelation,0)  and i.ParentExecuteBy10 in ('T', 'D') ) as x exec QBM_PDBQueueInsert_Bulk 'QBM-K-CommonMakeWatchtrigger', @DBQueueElements_01 end if UPDATE(ParentRestriction) or UPDATE(ParentExecuteBy11) or UPDATE(ChildRestriction) or UPDATE(ChildExecuteBy) or UPDATE(IsForUpdateXDateSubItem) begin declare @DBQueueElements_02 QBM_YDBQueueRaw insert into12 @DBQueueElements_02 (object, subobject, genprocid) select x.uid, null, @GenProcID from (select t.TableName as UID from deleted i join QBMRelation r on13 i.UID_QBMRelation = r.UID_QBMRelation join DialogColumn c on i.UID_ParentColumn = c.UID_DialogColumn join DialogTable t on c.UID_DialogTable = t.UID_DialogTable14 where (r.ParentRestriction <> i.ParentRestriction or r.ParentExecuteBy <> i.ParentExecuteBy or r.ChildRestriction <> i.ChildRestriction or r.ChildExecuteBy15 <> i.ChildExecuteBy or r.IsForUpdateXDateSubItem <> i.IsForUpdateXDateSubItem )  and r.ParentExecuteBy in ('T', 'D') union select t.TableName as UID from16 deleted i join QBMRelation r on i.UID_QBMRelation = r.UID_QBMRelation join DialogColumn c on i.UID_ChildColumn = c.UID_DialogColumn join DialogTable t17 on c.UID_DialogTable = t.UID_DialogTable where (r.ParentRestriction <> i.ParentRestriction or r.ParentExecuteBy <> i.ParentExecuteBy or r.ChildRestriction18 <> i.ChildRestriction or r.ChildExecuteBy <> i.ChildExecuteBy or r.IsForUpdateXDateSubItem <> i.IsForUpdateXDateSubItem )  and r.ParentExecuteBy in ('T'19, 'D') ) as x exec QBM_PDBQueueInsert_Bulk 'QBM-K-CommonMakeWatchtrigger', @DBQueueElements_02 end if update(ParentRestriction) or update(ParentExecuteBy20) or update(ChildRestriction) or update(ChildExecuteBy) or update(ParentAllowUpdate) begin   if exists (select top 1 1 from QBMRelation r join deleted 21d on r.UID_QBMRelation = d.UID_QBMRelation where (isnull(r.ParentRestriction, '') <> isnull(d.ParentRestriction, '') or isnull(r.ParentExecuteBy, '') <>22 isnull(d.ParentExecuteBy, '') or isnull(r.ChildRestriction, '') <> isnull(d.ChildRestriction, '') or isnull(r.ChildExecuteBy, '') <> isnull(d.ChildExecuteBy23, '') ) ) begin update QBMRelation set ParentExecuteBy = case v.ParentExecuteBy when 'N' then 'N' else 'T' end , ParentAllowUpdate = 0 , ParentRestriction24 = b.ParentRestriction , XDateUpdated = @Xdate , XUserUpdated = @XUser  from QBMRelation v join inserted  b on v.UID_QBMRelationBase = b.UID_QBMRelation25 where b.ParentExecuteBy = 'T' and ( v.ParentExecuteBy not in ('T', 'N') or v.ParentAllowUpdate = 1 or v.ParentRestriction <> b.ParentRestriction ) update26 QBMRelation set ParentExecuteBy = case v.ParentExecuteBy when 'N' then 'N' else 'D' end , ParentAllowUpdate = b.ParentAllowUpdate , ParentRestriction 27= case b.ParentAllowUpdate when 1 then v.ParentRestriction else b.ParentRestriction end , XDateUpdated = @Xdate , XUserUpdated = @XUser  from QBMRelation28 v join inserted  b on v.UID_QBMRelationBase = b.UID_QBMRelation where b.ParentExecuteBy = 'D' and ( v.ParentExecuteBy not in ('D', 'N') or v.ParentAllowUpdate29 <> b.ParentAllowUpdate or ( b.ParentAllowUpdate = 0 and b.ParentRestriction <> v.ParentRestriction ) ) end exec QBM_PDBQueueInsert_Single 'QBM-K-CommonMakeRITriggerPre'30, '', '', @GenProcID end  END TRY BEGIN CATCH exec QBM_PSessionErrorAdd default RAISERROR ('', 18, 1) WITH NOWAIT END CATCH end 31