﻿-- Stored procedure
CREATE PROCEDURE [dbo].[SP_PDF_DELETE]
	@IdPdf AS BIGINT,
	@idProvenienza varchar(1)
AS
BEGIN
	SET NOCOUNT ON; 
	declare @ROWCOUNT as int	 
	 UPDATE DocumentiPdf SET  idStato = 'E', dteliminato = getdate()
	 WHERE idPdf = @IdPdf and idStato <> 'E' 
 	 set @ROWCOUNT = @@ROWCOUNT
     INSERT INTO LogPdf (idPdf,dtstamp,idLogEvent,idProvenienza)	 
		SELECT  @IdPdf,
				GETDATE(),
				2 as idLogEvent,
				@idProvenienza
	return  @ROWCOUNT 
END