

-- =================================================================================================


/*****************************************
* STORED stp_OdetteStatoCreate
*
* Restituisce il numero di odette create e da creare per una PackList
*
* Steamware, S.E.L.
* mod: 2011.05.04
*
****************************************/
CREATE PROCEDURE [dbo].[stp_OdetteStatoCreate]
(
	@CodLista NVARCHAR(50)
)
AS

DECLARE @OdetteCreate	INT
DECLARE @OdetteDaCreare	INT

SET		@OdetteCreate	= (SELECT COUNT(o.CampoUDC)
							FROM Odette o INNER JOIN RigheListePrelievo rlp ON o.CampoUDC=rlp.UDC
							WHERE rlp.CodLista = @CodLista)
		
SET		@OdetteDaCreare = (SELECT COUNT(UDC)
							FROM RigheListePrelievo
							WHERE CodLista = @CodLista)

SELECT	ISNULL(@OdetteCreate,0) AS OdetteCreate, ISNULL(@OdetteDaCreare,0) AS OdetteDaCreare

RETURN

