Added logic to trigger to allow an unused library document to be deleted.
This commit is contained in:
parent
0b802cd9ce
commit
d2796abac7
@ -6514,3 +6514,32 @@ GO
|
||||
IF (@@Error = 0) PRINT 'Procedure Creation: vesp_ResetFolderManualOrderAlphabetical Succeeded'
|
||||
ELSE PRINT 'Procedure Creation: vesp_ResetFolderManualOrderAlphabetical Error on Creation'
|
||||
GO
|
||||
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[tr_Documents_Delete]') AND OBJECTPROPERTY(id,N'IsTrigger') = 1)
|
||||
DROP TRIGGER [tr_Documents_Delete];
|
||||
|
||||
/****** Object: Trigger [dbo].[tr_Documents_Delete] Script Date: 03/28/2013 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
/****** Object: Trigger [tr_Documents_Delete] ******/
|
||||
/*****************************************************************************
|
||||
Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
||||
Copyright 2013 - Volian Enterprises, Inc. All rights reserved.
|
||||
*****************************************************************************/
|
||||
CREATE trigger [dbo].[tr_Documents_Delete] on [dbo].[Documents] instead of delete as
|
||||
begin
|
||||
update ii set DeleteStatus = Isnull((select max(DeleteID) from DeleteLog where SPID = @@spid),-1), DTS = getdate(),
|
||||
UserID = IsNull((select top 1 UserID from DeleteLog where SPID = @@spid order by deleteid desc),ii.UserID)
|
||||
from tblDocuments ii inner join deleted dd on dd.DocID = ii.DocID
|
||||
insert into DocumentAudits(DocID,LibTitle,DocContent,DocAscii,Config,DTS,UserID,FileExtension,DeleteStatus)
|
||||
select ii.DocID,ii.LibTitle,ii.DocContent,ii.DocAscii,ii.Config,ii.DTS,ii.UserID,ii.FileExtension,ii.DeleteStatus
|
||||
from tblDocuments ii inner join deleted dd on dd.DocID = ii.DocID
|
||||
where ii.DeleteStatus != 0
|
||||
end
|
||||
GO
|
||||
-- Display the status of Trigger alter
|
||||
IF (@@Error = 0) PRINT 'Trigger alteration: tr_Documents_Delete Succeeded'
|
||||
ELSE PRINT 'Trigger alteration: tr_Documents_Delete Error on Alteration'
|
||||
GO
|
||||
|
Loading…
x
Reference in New Issue
Block a user