
/***************************************
* STORED stp_UDC_delete
*
* elimina un dato UDC
*
* Steamware, S.E.L.
* mod: 2012.09.25
*
****************************************/
create PROCEDURE stp_UDC_delete
(
	@UDC			NVARCHAR(50)
)
AS

BEGIN tran

	-- annullo cella piena
	UPDATE dbo.Celle
	SET Piena = 0
	FROM PosizioneUdcCorrente p
		INNER JOIN dbo.Celle c ON p.IdxCella = c.IdxCella
	WHERE c.Piena = 1 AND p.UDC = @UDC
	
	-- cancello posizione
	DELETE 
	FROM	PosizioneUdcCorrente
	WHERE	UDC = @UDC

	-- cancello UDC
	DELETE
	FROM	ElencoCartellini
	WHERE	UDC = @UDC

COMMIT tran

RETURN
