dbo.QBM_TUDialogDatabase
Database TriggerSQL_TRIGGERSandbox DB
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-GetServerProperties / QBM_ZGetServerProperties at line 9
- References QBM_PDBQueueInsert_Single
- Trigger parent table: DialogDatabase
Typed Edges
- queues DBQueue task QBM_ZGetServerProperties at line 9 Single DBQueue insert -> QBM-K-GetServerProperties / QBM_ZGetServerProperties at line 9
- trigger on table DialogDatabase Trigger parent table: DialogDatabase
- references source dbo.QBM_FGISessionContext source text reference
- references source dbo.QBM_FGISessionErrorRethrow source text reference
- references source dbo.QBM_FGIUserAccessLevel source text reference
- references source dbo.QBM_PDBQueueInsert_Single source text reference
- references source dbo.QBM_PSessionContextSet source text reference
- references source dbo.QBM_PSessionErrorAdd source text reference
References
- dbo.QBM_FGISessionContext
- dbo.QBM_FGISessionErrorRethrow
- dbo.QBM_FGIUserAccessLevel
- dbo.QBM_PDBQueueInsert_Single
- dbo.QBM_PSessionContextSet
- dbo.QBM_PSessionErrorAdd
Referenced By
- No direct source references extracted.
Complete Source
1CREATE trigger QBM_TUDialogDatabase2 ON DialogDatabase FOR3UPDATE NOT FOR Replication4AS5BEGIN6 SET XACT_ABORT OFF7 DECLARE @NewProductionlevel int8 DECLARE @ErrorMessage nvarchar(1000)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 IF NOT dbo.QBM_FGIUserAccessLevel() > 3 AND NOT(20 UPDATE(FESimulationStarted) OR21 UPDATE(XUserUpdated) OR22 UPDATE(XDateUpdated))23 BEGIN24 RAISERROR('#LDS#Access denied with AccessLevel <= 3|',25 18,26 1)27 WITH nowait28 END29 DECLARE @GenProcID varchar(38)30 SELECT @GenProcID = dbo.QBM_FGISessionContext('')31 IF32 UPDATE(ProductionLevel)33 BEGIN34 SELECT @NewProductionlevel = NULL35 SELECT TOP 1 @NewProductionlevel = db.ProductionLevel36 FROM DialogDatabase db37 JOIN deleted d38 ON db.UID_Database = d.UID_Database39 WHERE40 db.IsMainDatabase = 1 AND isnull(db.ProductionLevel,41 0) <> isnull(d.ProductionLevel,42 0)43 IF @NewProductionlevel > ' '44 BEGIN45 UPDATE DialogConfigParm46 SET Value = CASE @NewProductionlevel47 WHEN 0 THEN48 549 WHEN 1 THEN50 751 ELSE 052 END53 WHERE54 FullPath = 'QBM\DBQueue\CountSlotsMax'55 UPDATE DialogConfigParm56 SET Value = CASE @NewProductionlevel57 WHEN 0 THEN58 2059 WHEN 1 THEN60 4061 ELSE 12062 END63 WHERE64 FullPath = 'QBM\DBQueue\KeepAlive'65 END66 END67 IF68 UPDATE(DataOrigin)69 BEGIN70 EXEC QBM_PDBQueueInsert_Single 'QBM-K-GetServerProperties',71 '',72 '',73 @GenProcID74 END75 IF76 UPDATE(UID_CutOffTask)77 BEGIN78 IF(79 SELECT TOP 1 i.UID_CutOffTask80 FROM inserted i) IS NULL81 BEGIN82 EXEC QBM_PSessionContextSet 'INSERTEDINTODBQUEUE',83 '1'84 END85 ELSE86 BEGIN87 IF EXISTS(88 SELECT TOP 1 189 FROM deleted d90 JOIN DialogDatabase i91 ON d.UID_Database = i.UID_Database92 WHERE93 i.UID_CutOffTask IN('QBM-K-CommonWaitForCompiler', 'QBM-K-BaseMigrationReady') AND(d.UID_CutOffTask IS NULL OR i.UID_CutOffTask = d.UID_CutOffTask94 ))95 BEGIN96 EXEC QBM_PSessionContextSet 'INSERTEDINTODBQUEUE',97 '1'98 END99 ELSE100 BEGIN101 SELECT102 TOP 1 @ErrorMessage = CONCAT('#LDS#Invalid Update in column UID_CutOffTask. Old task: {0}, New task {1}.|',103 isnull(d.UID_CutOffTask, '<empty>'),104 '|',105 isnull(i.UID_CutOffTask, '<empty>'),106 '|')107 FROM deleted d108 JOIN DialogDatabase i109 ON d.UID_Database = i.UID_Database110 WHERE111 i.IsMainDatabase = 1112 IF @@TRANCOUNT > 0113 BEGIN114 ROLLBACK115 END116 RAISERROR(@ErrorMessage,117 18,118 1)119 WITH nowait120 END121 END122 END123 END TRY124 BEGIN CATCH125 EXEC QBM_PSessionErrorAdd DEFAULT126 DECLARE @Rethrow varchar(1000) = dbo.QBM_FGISessionErrorRethrow()127 RAISERROR(@Rethrow,128 18,129 1)130 WITH NOWAIT131 END CATCH132END
Open raw exported source
1 create trigger QBM_TUDialogDatabase on DialogDatabase for Update not for Replication as begin SET XACT_ABORT OFF declare @NewProductionlevel2 int declare @ErrorMessage nvarchar(1000) BEGIN TRY if exists (select top 1 1 from inserted) goto start if exists (select top 1 1 from deleted) goto start3 return start: if not dbo.QBM_FGIUserAccessLevel() > 3 and not (update(FESimulationStarted) or update(XUserUpdated) or update(XDateUpdated) ) begin raiserror4 ('#LDS#Access denied with AccessLevel <= 3|', 18, 1) with nowait end declare @GenProcID varchar(38) select @GenProcID = dbo.QBM_FGISessionContext('') 5if update(ProductionLevel) begin select @NewProductionlevel = null select top 1 @NewProductionlevel = db.ProductionLevel from DialogDatabase db join deleted6 d on db.UID_Database = d.UID_Database where db.IsMainDatabase = 1 and isnull(db.ProductionLevel, 0) <> isnull(d.ProductionLevel, 0) if @NewProductionlevel7 > ' ' begin update DialogConfigParm set Value = case @NewProductionlevel when 0 then 5 when 1 then 7 else 0 end where FullPath = 'QBM\DBQueue\CountSlotsMax'8 update DialogConfigParm set Value = case @NewProductionlevel when 0 then 20 when 1 then 40 else 120 end where FullPath = 'QBM\DBQueue\KeepAlive' end9 end if UPDATE(DataOrigin) begin exec QBM_PDBQueueInsert_Single 'QBM-K-GetServerProperties', '', '', @GenProcID end if update(UID_CutOffTask) begin if 10(select top 1 i.UID_CutOffTask from inserted i ) is null begin exec QBM_PSessionContextSet 'INSERTEDINTODBQUEUE', '1' end else begin if exists (select11 top 1 1 from deleted d join DialogDatabase i on d.UID_Database = i.UID_Database where i.UID_CutOffTask in ('QBM-K-CommonWaitForCompiler', 'QBM-K-BaseMigrationReady'12) and (d.UID_CutOffTask is null or i.UID_CutOffTask = d.UID_CutOffTask ) ) begin exec QBM_PSessionContextSet 'INSERTEDINTODBQUEUE', '1' end else begin13 select top 1 @ErrorMessage = concat('#LDS#Invalid Update in column UID_CutOffTask. Old task: {0}, New task {1}.|' , isnull(d.UID_CutOffTask, '<empty>'14), '|' , isnull(i.UID_CutOffTask, '<empty>'), '|' ) from deleted d join DialogDatabase i on d.UID_Database = i.UID_Database where i.IsMainDatabase = 1 15if @@TRANCOUNT > 0 begin rollback end raiserror (@ErrorMessage, 18, 1) with nowait end end end END TRY BEGIN CATCH exec QBM_PSessionErrorAdd default declare16 @Rethrow varchar(1000) = dbo.QBM_FGISessionErrorRethrow() RAISERROR (@Rethrow, 18, 1) WITH NOWAIT END CATCH end 17