set xact_abort on;
go

begin transaction;
go

set ANSI_NULLS on;
go

/***************************************
* STORED stp_Blocchi_Insert
*
* crea nuovo record blocchi magazzino
*
* Steamware, S.E.L.
* mod: 2012.02.29
*
****************************************/
create PROCEDURE stp_Blocchi_Insert
(

	@CodMag NVARCHAR(50),
	@CodCS NVARCHAR(2),
	@CodBlocco NVARCHAR(3),
	@DescBlocco NVARCHAR(50),
	@NumX INT,
	@NumY INT,
	@NumZ INT
)
AS

	INSERT INTO Blocchi (CodMag, CodCS, CodBlocco, DescBlocco, NumX, NumY, NumZ) 
	VALUES (@CodMag, @CodCS, @CodBlocco, @DescBlocco, @NumX, @NumY, @NumZ)
	
RETURN
go

commit;
go



set xact_abort on;
go

begin transaction;
go

set ANSI_NULLS on;
go

/***************************************
* STORED stp_LP_getOpenByUserTipo
*
* ottiene LP aperte da soggetto e tipo
*
* Steamware, S.E.L.
* mod: 2012.03.01
*
****************************************/
create PROCEDURE stp_LP_getOpenByUserTipo
(
	@CodSoggetto NVARCHAR(17),
	@CodTipoLista NVARCHAR(10)
)
AS

	SELECT	*
	FROM    V_elencoListePrelievo
	WHERE   (CodSoggetto = @CodSoggetto) AND (CodTipoLista = @CodTipoLista)
	AND		CodStatoLista < 3
	
RETURN
go

/***************************************
* STORED stp_LP_getOpenByUserTipoPart
*
* ottiene LP aperte da soggetto, tipo e particolare
*
* Steamware, S.E.L.
* mod: 2012.03.01
*
****************************************/
create PROCEDURE stp_LP_getOpenByUserTipoPart
(
	@CodSoggetto NVARCHAR(17),
	@CodTipoLista NVARCHAR(10),
	@Particolare VARCHAR(15)
)
AS

	SELECT	*
	FROM    V_elencoListePrelievo
	WHERE   (CodSoggetto = @CodSoggetto) AND (CodTipoLista = @CodTipoLista) AND (Particolare = @Particolare)
	AND		CodStatoLista < 3
	
RETURN
go

commit;
go


set xact_abort on;
go

begin transaction;
go

set ANSI_NULLS on;
go

/***************************************
* STORED stp_RLP_deleteFromCodLista
*
* cancella righe UDC dato cod lista
*
* Steamware, S.E.L.
* mod: 2012.02.29
*
****************************************/
create PROCEDURE stp_RLP_deleteFromCodLista
(
	@Original_CodLista AS varchar(12)
)
AS

	-- cancello
	DELETE FROM	RigheListePrelievo
	WHERE		CodLista = @Original_CodLista 

RETURN
go

/***************************************
* STORED stp_RLP_getByUdc
*
* ottiene RLP da UDC
*
* Steamware, S.E.L.
* mod: 2012.02.29
*
****************************************/
create PROCEDURE stp_RLP_getByUdc
(
	@UDC VARCHAR(50)
)
AS

	SELECT	*
	FROM    RigheListePrelievo
	WHERE   (UDC = @UDC)
	
RETURN
go

/***************************************
* STORED stp_RLP_getOpenByUserTipo
*
* ottiene RLP aperte da soggetto e tipo
*
* Steamware, S.E.L.
* mod: 2012.03.01
*
****************************************/
create PROCEDURE stp_RLP_getOpenByUserTipo
(
	@CodSoggetto NVARCHAR(17),
	@CodTipoLista NVARCHAR(10)
)
AS

	SELECT	RLP.*
	FROM    V_elencoListePrelievo LP INNER JOIN RigheListePrelievo RLP ON LP.CodLista = RLP.CodLista
	WHERE   (LP.CodSoggetto = @CodSoggetto) AND (LP.CodTipoLista = @CodTipoLista)
	AND		LP.CodStatoLista < 3
	
RETURN
go

commit;
go







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