
set xact_abort on
go

begin transaction
go

alter table AS400_BatchConsumoMP alter column
  TurnoPrelFus nvarchar(50) not null
go

alter table AS400_BatchConsumoMP alter column
  DestLega nvarchar(50)
go

alter table AS400_BatchConsumoMP alter column
  DestTerz nvarchar(50)
go

commit
go


set xact_abort on
go

begin transaction
go

set ANSI_NULLS on
go

/***************************************
* STORED stp_accodaConsumoUdcMP
*
* Accoda alla tab Batch il consumo di un UDC
*
* Steamware, S.E.L.
* mod: 2010.10.10
*
****************************************/
alter PROCEDURE stp_accodaConsumoUdcMP
(
	@UDC NVARCHAR(50),
	@DataPrelFus DATETIME,
	@TurnoPrelFus NVARCHAR(5),
	@DestLega NVARCHAR(3),
	@DestTerz NVARCHAR(6)	
)
AS

BEGIN TRAN

	-- registro movimento da riconciliare
	INSERT INTO AS400_BatchConsumoMP(ProgUDC, UDC, DataPrelFus, TurnoPrelFus, DestLega, DestTerz)
	SELECT ProgUdc, UDC, dbo.dateToAsFormat(@DataPrelFus), LTRIM(RTRIM(@TurnoPrelFus)), LTRIM(RTRIM(@DestLega)), LTRIM(RTRIM(@DestTerz)) 
	FROM RilPro.RapQual WHERE UDC = @UDC

	-- aggiorno con data e turno di prelievo su tab RilPro (locale)
	UPDATE RilPro.RapQual
	SET DataPrelFus = dbo.dateToAsFormat(@DataPrelFus), TurnoPrelFus = LTRIM(RTRIM(@TurnoPrelFus))
	WHERE UDC = @UDC

COMMIT TRAN

RETURN
go

commit
go





-- registro versione...
INSERT INTO [dbo].[LogUpdateDb] ([Versione],[Data]) VALUES(287, GETDATE())
GO
