Back to OIM Explorer

dbo.QBM_TIDialogSchedule

Database TriggerSQL_TRIGGERSandbox DB

Database Trigger on DialogSchedule. Trigger parent table: DialogSchedule

Source: sandbox-db sys.sql_modules

Source size: 2.021 characters

Interpretation

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

Relations

  • Trigger parent table: DialogSchedule

Typed Edges

  • trigger on table DialogSchedule Trigger parent table: DialogSchedule
  • references source dbo.QBM_FGIScheduleNextRun source text reference
  • references source dbo.QBM_FGISessionContext source text reference
  • references source dbo.QBM_FGITimeIsValid source text reference
  • references source dbo.QBM_PSessionErrorAdd source text reference

References

Referenced By

  • No direct source references extracted.

Complete Source

SQL81 lines
1CREATE trigger QBM_TIDialogSchedule2  ON DialogSchedule FOR3INSERT NOT FOR Replication4AS5BEGIN6  DECLARE @jetzt datetime = getutcdate()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    RETURN start:15    DECLARE @GenProcID varchar(38)16    SELECT @GenProcID = dbo.QBM_FGISessionContext('')17    IF EXISTS(18      SELECT TOP 1 119      FROM inserted i20      WHERE21        dbo.QBM_FGITimeIsValid(i.starttime) < 0)22    BEGIN23      RAISERROR('#LDS#The time entered is not valid, must be between 00:00 and 23:59 or empty.|',24      18,25      3)26        WITH nowait27    END28    UPDATE DialogSchedule29    SET EndDate = '2200-01-01',30    XDateUpdated = @Xdate,31    XUserUpdated = @XUser32    FROM DialogSchedule s33    JOIN inserted i34      ON s.UID_DialogSchedule = i.UID_DialogSchedule35    WHERE36      s.EndDate IS NULL37    UPDATE DialogSchedule38    SET NextRun = dbo.QBM_FGIScheduleNextRun('1899-12-31',39    '1899-12-31',40    CASE41      WHEN isnull(s.StartDate, '1900-01-01') > @jetzt AND s.FrequencyType NOT IN('Week', 'Month', 'Year', 'Day') THEN42    s.StartDate43      WHEN isnull(s.StartDate, '1900-01-01') > @jetzt AND s.FrequencyType IN('Week', 'Month', 'Year') THEN44    dateadd(dd, -1, s.StartDate)45      WHEN isnull(s.StartDate, '1900-01-01') > @jetzt AND s.FrequencyType IN('Day') THEN46    dateadd(hh, -1, s.StartDate)47    ELSE @jetzt48    END,49    s.StartTime,50    s.FrequencyType,51    CASE52      WHEN isnull(s.StartDate, '1900-01-01') > @jetzt AND s.FrequencyType NOT IN('Week', 'Month', 'Year', 'Day') AND s.FrequencyType NOT LIKE 'WD[_]%'53    THEN54    055      WHEN s.FrequencyType LIKE 'WD[_]%' THEN56    s.Frequency57    ELSE 158    END,59    s.FrequencySubType,60    isnull(tz.CurrentUTCOffset, 0)),61    XDateUpdated = @Xdate,62    XUserUpdated = @XUser63    FROM DialogSchedule s64    JOIN inserted i65      ON s.UID_DialogSchedule = i.UID_DialogSchedule66    LEFT67    OUTER68    JOIN DialogTimeZone tz69      ON s.UID_DialogTimeZone = tz.UID_DialogTimeZone70    WHERE71      isnull(s.EndDate,72    '2200-01-01') > @jetzt AND s.Enabled = 173  END TRY74  BEGIN CATCH75    EXEC QBM_PSessionErrorAdd DEFAULT76    RAISERROR('',77    18,78    1)79      WITH NOWAIT80  END CATCH81END
Open raw exported source
SQL ยท Raw14 lines
1  create   trigger QBM_TIDialogSchedule on DialogSchedule  for insert not for Replication as begin declare @jetzt datetime = getutcdate() declare2 @XUser nvarchar(64) = object_name(@@procid) declare @Xdate datetime = getutcdate() BEGIN TRY if exists (select top 1 1 from inserted) goto start return3 start: declare @GenProcID varchar(38) select @GenProcID = dbo.QBM_FGISessionContext('') if exists (select top 1 1 from inserted i where dbo.QBM_FGITimeIsValid4(i.starttime) < 0 ) begin  raiserror( '#LDS#The time entered is not valid, must be between 00:00 and 23:59 or empty.|', 18, 3) with nowait end  update 5DialogSchedule set EndDate = '2200-01-01' , XDateUpdated = @Xdate , XUserUpdated = @XUser from DialogSchedule s join inserted i on s.UID_DialogSchedule6 = i.UID_DialogSchedule where s.EndDate is null update DialogSchedule set NextRun = dbo.QBM_FGIScheduleNextRun ('1899-12-31'  , '1899-12-31'  , case  when7 isnull(s.StartDate, '1900-01-01') > @jetzt and s.FrequencyType not in ('Week', 'Month', 'Year', 'Day') then s.StartDate when isnull(s.StartDate, '1900-01-01'8) > @jetzt and s.FrequencyType in ('Week', 'Month', 'Year') then dateadd (dd, -1, s.StartDate) when isnull(s.StartDate, '1900-01-01') > @jetzt and s.FrequencyType9 in ('Day') then dateadd (hh, -1, s.StartDate) else @jetzt end , s.StartTime  , s.FrequencyType  ,  case when isnull(s.StartDate, '1900-01-01') > @jetzt10  and s.FrequencyType not in ('Week', 'Month', 'Year', 'Day') and s.FrequencyType not like 'WD[_]%' then 0 when s.FrequencyType like 'WD[_]%' then s.Frequency11 else 1 end , s.FrequencySubType  , isnull(tz.CurrentUTCOffset, 0)  ) , XDateUpdated = @Xdate , XUserUpdated = @XUser from DialogSchedule s join inserted12 i on s.UID_DialogSchedule = i.UID_DialogSchedule left outer join DialogTimeZone tz on s.UID_DialogTimeZone = tz.UID_DialogTimeZone where isnull(s.EndDate13, '2200-01-01') > @jetzt  and s.Enabled = 1 END TRY BEGIN CATCH exec QBM_PSessionErrorAdd default RAISERROR ('', 18, 1) WITH NOWAIT END CATCH end 14