
[dbo].[CreateCacheUpdateNotifications]
CREATE PROCEDURE [dbo].[CreateCacheUpdateNotifications]
@ReportID uniqueidentifier,
@LastRunTime datetime
AS
update [Subscriptions]
set
[LastRunTime] = @LastRunTime
from
[Subscriptions] S
where
S.[Report_OID] = @ReportID and S.EventType = 'SnapshotUpdated' and InactiveFlags = 0
insert into [Notifications]
(
[NotificationID],
[SubscriptionID],
[ActivationID],
[ReportID],
[SnapShotDate],
[ExtensionSettings],
[Locale],
[Parameters],
[NotificationEntered],
[SubscriptionLastRunTime],
[DeliveryExtension],
[SubscriptionOwnerID],
[IsDataDriven],
[Version]
)
select
NewID(),
S.[SubscriptionID],
NULL,
S.[Report_OID],
NULL,
S.[ExtensionSettings],
S.[Locale],
S.[Parameters],
GETUTCDATE(),
S.[LastRunTime],
S.[DeliveryExtension],
S.[OwnerID],
0,
S.[Version]
from
[Subscriptions] S inner join Catalog C on S.[Report_OID] = C.[ItemID]
where
C.[ItemID] = @ReportID and S.EventType = 'SnapshotUpdated' and InactiveFlags = 0 and
S.[DataSettings] is null
insert into [Event]
(
[EventID],
[EventType],
[EventData],
[TimeEntered]
)
select
NewID(),
'DataDrivenSubscription',
S.SubscriptionID,
GETUTCDATE()
from
[Subscriptions] S inner join Catalog C on S.[Report_OID] = C.[ItemID]
where
C.[ItemID] = @ReportID and S.EventType = 'SnapshotUpdated' and InactiveFlags = 0 and
S.[DataSettings] is not null
GO
GRANT EXECUTE ON [dbo].[CreateCacheUpdateNotifications] TO [RSExecRole]
GO