2025-06-25 11:25:55 +02:00

40 lines
999 B
Transact-SQL

CREATE procedure [dbo].[HIST_GETIMAGE]
@id as int,
@repository as int,
@idMetadato as int
as
BEGIN
SET NOCOUNT ON;
IF(@repository = 0)
BEGIN
SELECT [FILEREPORT]
FROM [dbo].[REPORTFISICO]
WHERE IDENTIFICATIVO=@ID
END
ELSE IF (@repository = 2)
BEGIN
SELECT [IMAGE] AS FILEREPORT
FROM [dbo].[C6REPORTFISICO_CAMPAGNA]
WHERE IDENTIFICATIVO=@ID
END
ELSE IF(@repository = 1)
BEGIN
SELECT [IMAGE]
FROM [dbo].[C6REPORTFISICO]
WHERE IDENTIFICATIVO=@ID
END
ELSE IF(@repository = 5) --FMS
BEGIN
SELECT [FileReport]
FROM [SEIReport].[dbo].[ReportFMS]
WHERE [Identificativo]=@ID
END
--verificare se la condizione repository = 4 è corretta metterla qui, e se si rimuoverla dalla [dbo].[HIST_DELETEARCHIVIATI]
update repositoryMetadati
set flagStoricizzato = 1, repositoryPrestorico = repository, repository = 4
where id = @idMetadato
-- aggiorno tabella di input
Update appoDaArchiviare
set flagArchiviato=1
where idInmetadati=@idMetadato
end