DROP PROCEDURE IN_COMPETITIONPRICEInsProc
GO
CREATE PROCEDURE IN_COMPETITIONPRICEInsProc
(	@CORRNBR	INT

)
AS
BEGIN
	BEGIN TRAN


	INSERT 	INTO IN_COMPETITIONPRICE(SITEID,DATEPROCE,INVTIDSKU,PRICESUGGESTED,PRICECURRENT,PRICEPREVIOUS)
	SELECT  SITEID,DATEPROCE,INVTIDSKU,PRICESUGGESTED,PRICECURRENT,PRICEPREVIOUS FROM TMP_IN_COMPETITIONPRICE
	WHERE 	CORRNBR=@CORRNBR
	
	IF(@@ERROR!=0 OR @@ROWCOUNT=0)
	BEGIN
		ROLLBACK
		RAISERROR 20000 'Error Insentando Registros'
		RETURN(1)
	END 

	COMMIT TRAN
	RETURN(0)
END 
